本文整理汇总了Java中org.nutz.dao.Dao类的典型用法代码示例。如果您正苦于以下问题:Java Dao类的具体用法?Java Dao怎么用?Java Dao使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Dao类属于org.nutz.dao包,在下文中一共展示了Dao类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dropEntity
import org.nutz.dao.Dao; //导入依赖的package包/类
public boolean dropEntity(Dao dao, Entity<?> en) {
String tableName = en.getTableName();
String viewName = en.getViewName();
try {
dropRelation(dao, en);
if (!tableName.equals(viewName) && dao.exists(viewName)) {
dao.execute(Sqls.create("DROP VIEW " + viewName));
}
dao.execute(Sqls.create("DROP TABLE " + tableName));
}
catch (Exception e) {
return false;
}
return true;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:17,代码来源:AbstractJdbcExpert.java
示例2: dropEntity
import org.nutz.dao.Dao; //导入依赖的package包/类
@Override
public boolean dropEntity(Dao dao, Entity<?> en) {
if (super.dropEntity(dao, en)) {
if (en.getPks().isEmpty())
return true;
List<Sql> sqls = new ArrayList<Sql>();
for (MappingField pk : en.getPks()) {
if (pk.isAutoIncreasement()) {
String sql = gSQL(DSEQ, en.getTableName(), pk.getColumnName());
sqls.add(Sqls.create(sql));
}
}
try {
dao.execute(sqls.toArray(new Sql[sqls.size()]));
return true;
}
catch (Exception e) {}
}
return false;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:21,代码来源:OracleJdbcExpert.java
示例3: addComment
import org.nutz.dao.Dao; //导入依赖的package包/类
private void addComment(Dao dao, Entity<?> en, String commentColumn) {
// TODO 表注释 SQLServer2005中貌似不行
// 字段注释
if (en.hasColumnComment()) {
List<Sql> sqls = new ArrayList<Sql>();
for (MappingField mf : en.getMappingFields()) {
if (mf.hasColumnComment()) {
Sql columnCommentSQL = Sqls.create(commentColumn);
columnCommentSQL.vars()
.set("table", en.getTableName())
.set("column", mf.getColumnName())
.set("columnComment", mf.getColumnComment());
sqls.add(columnCommentSQL);
}
}
// 执行创建语句
dao.execute(sqls.toArray(new Sql[sqls.size()]));
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:20,代码来源:Sqlserver2005JdbcExpert.java
示例4: test04
import org.nutz.dao.Dao; //导入依赖的package包/类
@Test
public void test04() throws Exception {
SimpleDataSource dataSource = new SimpleDataSource();
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/take");
dataSource.setUsername("root");
dataSource.setPassword("root");
Dao dao = new NutDao(dataSource);
Daos.createTablesInPackage(dao, "com.jt.stock.model", false);
}
开发者ID:jt120,项目名称:take,代码行数:11,代码来源:LoginTest.java
示例5: init
import org.nutz.dao.Dao; //导入依赖的package包/类
@Override
public void init(NutConfig nc) {
Ioc ioc = nc.getIoc();
ioc.get(NutQuartzCronJobFactory.class);
Dao dao = ioc.get(Dao.class);
Daos.createTablesInPackage(dao, "com.yjh", false);
}
开发者ID:yangjinhe,项目名称:maintain-robot,代码行数:8,代码来源:MainSetup.java
示例6: dao
import org.nutz.dao.Dao; //导入依赖的package包/类
public Dao dao() {
if (dao == null) {
dao = Mvcs.ctx().getDefaultIoc().get(Dao.class, "dao");
return dao;
}
return dao;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:8,代码来源:SimpleAuthorizingRealm.java
示例7: dao
import org.nutz.dao.Dao; //导入依赖的package包/类
private Dao dao() {
if (null == dao) {
Ioc ioc = Mvcs.getIoc();
if (null == ioc)
ioc = Mvcs.ctx.getDefaultIoc();
dao = ioc.get(Dao.class);
}
return dao;
}
开发者ID:TopCoderMyDream,项目名称:LuliChat,代码行数:10,代码来源:AuthenticationFilter.java
示例8: init
import org.nutz.dao.Dao; //导入依赖的package包/类
public void init(NutConfig conf) {
Ioc ioc = conf.getIoc();
Dao dao = ioc.get(Dao.class);
Daos.createTablesInPackage(dao, "com.window", false);
// 初始化默认根用户
if (dao.count(User.class) == 0) {
User user = new User();
user.setName("admin");
user.setPassword("123456");
user.setCreateTime(new Date(System.currentTimeMillis()));
user.setUpdateTime(new Date(System.currentTimeMillis()));
dao.insert(user);
}
}
开发者ID:strictnerd,项目名称:windows-file-change,代码行数:15,代码来源:MainSetup.java
示例9: query
import org.nutz.dao.Dao; //导入依赖的package包/类
/**
* 查询sql并把结果放入传入的class组成的List中
*/
public static <T> List<T> query(Dao dao, Class<T> classOfT, String sql, Condition cnd, Pager pager) {
Sql sql2 = Sqls.queryEntity(sql);
sql2.setEntity(dao.getEntity(classOfT));
sql2.setCondition(cnd);
sql2.setPager(pager);
dao.execute(sql2);
return sql2.getList(classOfT);
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:12,代码来源:Daos.java
示例10: checkTableColumn
import org.nutz.dao.Dao; //导入依赖的package包/类
/**
* 检查分表中是否有字段变化 提示
*
* @param dao
* @param tableName
* @param clsType
*/
public static void checkTableColumn(Dao dao, Object tableName, final Class<?> clsType) {
final NutDao d = (NutDao) dao;
final JdbcExpert expert = d.getJdbcExpert();
ext(d, tableName).run(new ConnCallback() {
public void invoke(Connection conn) throws Exception {
Entity<?> en = d.getEntity(clsType);
expert.setupEntityField(conn, en);
}
});
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:19,代码来源:Daos.java
示例11: getTableName
import org.nutz.dao.Dao; //导入依赖的package包/类
/**
* 获取动态表的表名
*/
public static String getTableName(Dao dao, Class<?> klass, Object t) {
final Entity<?> en = dao.getEntity(klass);
if (t == null)
return en.getTableName();
final String[] name = new String[1];
TableName.run(t, new Runnable() {
public void run() {
name[0] = en.getTableName();
}
});
return name[0];
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:17,代码来源:Daos.java
示例12: createRelation
import org.nutz.dao.Dao; //导入依赖的package包/类
protected void createRelation(Dao dao, Entity<?> en) {
final List<Sql> sqls = new ArrayList<Sql>(5);
for (LinkField lf : en.visitManyMany(null, null, null)) {
ManyManyLinkField mm = (ManyManyLinkField) lf;
if (dao.exists(mm.getRelationName()))
continue;
String sql = "CREATE TABLE " + mm.getRelationName() + "(";
sql += mm.getFromColumnName() + " " + evalFieldType(mm.getHostField()) + ",";
sql += mm.getToColumnName() + " " + evalFieldType(mm.getLinkedField());
sql += ")";
sqls.add(Sqls.create(sql));
}
dao.execute(sqls.toArray(new Sql[sqls.size()]));
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:15,代码来源:AbstractJdbcExpert.java
示例13: dropRelation
import org.nutz.dao.Dao; //导入依赖的package包/类
protected void dropRelation(Dao dao, Entity<?> en) {
final List<Sql> sqls = new ArrayList<Sql>(5);
for (LinkField lf : en.visitManyMany(null, null, null)) {
ManyManyLinkField mm = (ManyManyLinkField) lf;
if (!dao.exists(mm.getRelationName()))
continue;
sqls.add(Sqls.create("DROP TABLE " + mm.getRelationName()));
}
dao.execute(sqls.toArray(new Sql[sqls.size()]));
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:11,代码来源:AbstractJdbcExpert.java
示例14: addComment
import org.nutz.dao.Dao; //导入依赖的package包/类
public void addComment(Dao dao, Entity<?> en, String commentTable, String commentColumn) {
if (!en.hasTableComment() && !en.hasColumnComment()) {
return;
}
List<Sql> sqls = new ArrayList<Sql>();
// 表注释
if (en.hasTableComment()) {
Sql tableCommentSQL = Sqls.create(Strings.isBlank(commentTable) ? DEFAULT_COMMENT_TABLE
: commentTable);
tableCommentSQL.vars()
.set("table", en.getTableName())
.set("tableComment", en.getTableComment());
sqls.add(tableCommentSQL);
}
// 字段注释
if (en.hasColumnComment()) {
for (MappingField mf : en.getMappingFields()) {
if (mf.hasColumnComment()) {
Sql columnCommentSQL = Sqls.create(Strings.isBlank(commentColumn) ? DEFAULT_COMMENT_COLUMN
: commentColumn);
columnCommentSQL.vars()
.set("table", en.getTableName())
.set("column", mf.getColumnName())
.set("columnComment", mf.getColumnComment());
sqls.add(columnCommentSQL);
}
}
}
// 执行创建语句
dao.execute(sqls.toArray(new Sql[sqls.size()]));
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:32,代码来源:AbstractJdbcExpert.java
示例15: reloadEntity
import org.nutz.dao.Dao; //导入依赖的package包/类
/**
* 重新载入
*/
public <T> Entity<T> reloadEntity(Dao dao, Class<T> classOfT) {
final Entity<T> re = maker.make(classOfT);
map.put(classOfT, re);
support.expert.createEntity(dao, re);
// 最后在数据库中验证一下实体各个字段
support.run(new ConnCallback() {
public void invoke(Connection conn) throws Exception {
support.expert.setupEntityField(conn, re);
}
});
return re;
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:16,代码来源:EntityHolder.java
示例16: init
import org.nutz.dao.Dao; //导入依赖的package包/类
@Override
public void init(NutConfig nc) {
String pkg = Iots.class.getPackage().getName();
for (int i = 0; i < Iots.PART; i++) {
Dao dao = Daos.ext(nc.getIoc().get(Dao.class), ""+i);
Daos.createTablesInPackage(dao, pkg, false);
}
iotService.rootUser();
nc.getIoc().get(IotNettyService.class);
log.info("iot setup complete");
}
开发者ID:wendal,项目名称:whale,代码行数:12,代码来源:IotSetup.java
示例17: ext
import org.nutz.dao.Dao; //导入依赖的package包/类
/**
* 创建一个带FieldFilter的Dao代理实例. 注意,为避免出错,生成的Dao对象不应该传递到其他方法去.
* @param dao 原始的Dao实例
* @param filter 字段过滤器
* @return 带FieldFilter的Dao代理实例
*/
public static Dao ext(Dao dao, FieldFilter filter) {
if (filter == null)
return dao;
ExtDaoInvocationHandler handler = new ExtDaoInvocationHandler(dao, filter, null);
return (Dao) Proxy.newProxyInstance(dao.getClass().getClassLoader(), iz, handler);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:13,代码来源:ExtDaos.java
示例18: init
import org.nutz.dao.Dao; //导入依赖的package包/类
@Override
public void init(NutConfig nc) {
Ioc ioc = nc.getIoc();
Dao dao = ioc.get(Dao.class);
Daos.createTablesInPackage(dao, WxUser.class.getPackage().toString(), false);
// PropertiesProxy pp = ioc.get(PropertiesProxy.class, "config");
// 按需选择
ResourceService resourceService = null;
// try {
// SSDB ssdb = SSDBs.pool("127.0.0.1", 8888, 5000, null);
// resourceService = new SsdbResourceService(ssdb);
// ((Ioc2)ioc).getIocContext().save("app", "resourceService", new ObjectProxy(resourceService));
// } catch (Exception e) {
// log.info("fail to connect ssdb? using DaoResourceService now", e);
resourceService = new DaoResourceService(dao);
((Ioc2)ioc).getIocContext().save("app", "resourceService", new ObjectProxy(resourceService));
// }
// try {
// scheduler = StdSchedulerFactory.getDefaultScheduler();
// scheduler.startDelayed(5000);;
// } catch (SchedulerException e) {
// log.warn("Scheduler start fail", e);
// }
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:29,代码来源:WxSetup.java
示例19: addMP
import org.nutz.dao.Dao; //导入依赖的package包/类
public void addMP(final WxMpInfo mp) {
if (mp == null || mp.getOpenid() == null)
return;
final Dao dao = ExtDaos.ext(this.dao, mp.getOpenid());
dao.create(WxMsgHistory.class, false);
dao.create(WxMsgStore.class, false);
masters.put(mp.getOpenid(), mp);
WxAPI api = new WxApiImpl(mp) {
public void reflushAccessToken() {
super.reflushAccessToken();
dao.update(mp, "^(access_token)");
}
@Override
public void send(WxOutMsg out) {
super.send(out);
wxHistory.push(out);
}
};
apis.put(mp.getOpenid(), api);
WxHandler handler = null;
if (Strings.isBlank(mp.getHandlerClass())) {
handler = new EnhandWxHandler();
} else {
try {
handler = (WxHandler) Mvcs.ctx().getDefaultIoc().get(Class.forName(mp.getHandlerClass()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (handler instanceof EnhandWxHandler)
((EnhandWxHandler)handler).setToken(mp.getToken());
handlers.put(mp.getOpenid(), handler);
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:35,代码来源:NutDaoWxContext.java
示例20: init
import org.nutz.dao.Dao; //导入依赖的package包/类
@Override
public void init(NutConfig nc) {
String pkg = IotSensor.class.getPackage().toString();
for (int i = 0; i < Iots.PART; i++) {
Dao dao = Daos.ext(nc.getIoc().get(Dao.class), ""+i);
Daos.createTablesInPackage(dao, pkg, false);
}
iotService.rootUser();
log.info("iot setup complete");
}
开发者ID:amdiaosi,项目名称:nutzWx,代码行数:11,代码来源:IotSetup.java
注:本文中的org.nutz.dao.Dao类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论