当前位置: 首页>>代码示例>>Java>>正文


Java Dao类代码示例

本文整理汇总了Java中org.nutz.dao.Dao的典型用法代码示例。如果您正苦于以下问题:Java Dao类的具体用法?Java Dao怎么用?Java Dao使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Dao类属于org.nutz.dao包,在下文中一共展示了Dao类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.nutz.dao.Dao类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。