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


Java Db.find方法代码示例

本文整理汇总了Java中com.jfinal.plugin.activerecord.Db.find方法的典型用法代码示例。如果您正苦于以下问题:Java Db.find方法的具体用法?Java Db.find怎么用?Java Db.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jfinal.plugin.activerecord.Db的用法示例。


在下文中一共展示了Db.find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateMappingModel

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void generateMappingModel(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingmodel.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingModel.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例2: generateMappingRoute

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void generateMappingRoute(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingroute.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingRoute.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例3: test_controller

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void test_controller() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
   DbModel model = DbModel.dao.findById(id);
   List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
   Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

   // 查找出跟model有关的list
   List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
   // 查找出跟model相关的从表
   List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

   Template t = gt.getTemplate("gen/web/4Jfinalcontroller.btl");
   t.binding("model", model);
   t.binding("columns", columns);

   t.binding("generate", generate);
   t.binding("master", master);
   t.binding("slaves", slaves);
   // 是否使用驼峰命名
   t.binding("camelName", true);
   System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例4: test_service

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void test_service() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4curd&webservice.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例5: test_sqlmd

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void test_sqlmd() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4mysqlmd.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例6: getResult

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public static List<Record> getResult(String id, Map<String, Object> paras){
	String _sql = get(id, paras);
	Object[] objs = new Object[paras.size()];
	Iterator<String> it = paras.keySet().iterator();
	int index = 0;
	while (it.hasNext()) {
		String key = it.next();
		Object obj = paras.get(key);
		objs[index++] = obj;
	}
	return Db.find(_sql, objs);
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:13,代码来源:SQL.java

示例7: test_pojo

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public void test_pojo() {
    // 基础目录
//    String basePath = "";
    int id = 5;
    gt.registerFunction("camelNameConvert", new CamelNameConvert());
    gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
    gt.registerFunction("toLowerCase", new ToLowerCase());

    DbModel model = DbModel.dao.findById(id);
    List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
    Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

    // 查找出跟model有关的list
    List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
    // 查找出跟model相关的从表
    List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

    Template t = gt.getTemplate("gen/pojo/4ActiveRecordEnhance.btl");
    t.binding("model", model);
    t.binding("columns", columns);

    t.binding("importNotNull", true);
    t.binding("importLength", true);
    t.binding("importNotBlank", true);

    t.binding("generate", generate);
    t.binding("master", master);
    t.binding("slaves", slaves);
    // 是否使用驼峰命名
    t.binding("camelName", true);
    System.out.println(t.render());
  }
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:33,代码来源:TempletGenerateTest.java

示例8: getTreeNode

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
private List<Record> getTreeNode(int projectId) {
  return Db.find("SELECT f.id folder_id, f.name folder_name, i.* FROM w_folder f LEFT JOIN w_interface i ON f.id = i.w_folder_id WHERE f.w_project_id = ? ORDER BY f.name, i.seq", projectId);
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:4,代码来源:ProjectController.java

示例9: getGenerateParamter

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public Map<String, Object> getGenerateParamter(DbModel model, boolean isCamelName) {
  if ( model == null || model.getId() == null )
    throw new GenerateException("Oop~ model is null.");
  Object id = model.getId();

  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  List<Record> slaves = Db.find("select a.class_name, b.*, c.package, c.module_name from w_db_model a, w_db_model_mapping b, w_generate c where a.id = b.slaves_id and b.master_id = ? and c.w_model_id = b.slaves_id", id);

  boolean
          // for String
          importNotBlank = false,
          // for String
          importLength = false,
          // for Object
          importNotNull = false;

  for ( DbModelItem column : columns ) {
    if ( column.getJavaType().equals("java.lang.String") ) {
      importLength = true;
    }
    if ( column.getIsRequired() == true && !column.getName().equals("id") ) {
      if ( column.getJavaType().equals("java.lang.String") ) {
        importNotBlank = true;
      } else {
        importNotNull = true;
      }
    }
  }

  Map<String, Object> paras = new HashMap<>();
  paras.put("generate", generate);

  paras.put("model", model);
  paras.put("columns", columns);

  paras.put("master", master);
  paras.put("slaves", slaves);
  paras.put("camelName", isCamelName);

  paras.put("importNotBlank", importNotBlank);
  paras.put("importLength", importLength);
  paras.put("importNotNull", importNotNull);

  return paras;
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:49,代码来源:TempletGenerate.java

示例10: find

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
public Sheet find(String sql, Object... params)
{
	return new Sheet(Db.find(asterisk(sql, params), unpack(params)));
}
 
开发者ID:glaciall,项目名称:jfinal-dbx,代码行数:5,代码来源:DbEx.java

示例11: findBy

import com.jfinal.plugin.activerecord.Db; //导入方法依赖的package包/类
/**
 * Query the database record set.
 *
 * @param sqlSelect SqlNode Select
 * @return query result.
 * @see SqlSelect
 * @see FindBy
 */
public static List<Record> findBy(SqlSelect sqlSelect) {
    Preconditions.checkNotNull(sqlSelect, "The Query SqlNode is must be not null.");
    return Db.find(sqlSelect.toString(), sqlSelect.getParams().toArray());
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:13,代码来源:Dao.java


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