Exemplo n.º 1
0
 private static void setParameter(SQLQuery sqlQuery, Object... params) {
   if (Validator.isNotEmpty(params)) {
     for (int i = 0; i < params.length; i++) {
       sqlQuery.setParameter(i, params[i]);
     }
   }
 }
Exemplo n.º 2
0
 /**
  * 判断数据库表是否存在(只适用于DB2)
  *
  * @param schema
  * @param tableName
  * @return true:存在;false:不存在
  * @author LiuKun
  * @throws SQLException
  * @created 2012-8-9 下午7:29:24
  */
 @Transactional
 public Boolean existTableForDB2(String schema, String tableName) {
   if (Validator.isEmpty(schema)) {
     throw new RuntimeException("schema为空!");
   }
   if (Validator.isEmpty(tableName)) {
     throw new RuntimeException("tableName为空!");
   }
   String sql = " SELECT NAME FROM SYSIBM.SYSTABLES WHERE CREATOR = ? AND NAME = ?  ";
   List<Map<String, Object>> mapList =
       executeQuery(sql, null, schema.toUpperCase(), tableName.toUpperCase());
   if (Validator.isNotEmpty(mapList)) {
     return Boolean.TRUE;
   } else {
     return Boolean.FALSE;
   }
 }
Exemplo n.º 3
0
 /**
  * 检测某个属性值是否存在
  *
  * @param clazz
  * @param propertyName
  * @param value
  * @return
  * @author LiuKun
  * @created 2012-7-28 上午11:36:02
  */
 @Transactional
 public <E extends Entity> Boolean checkExist(Class<E> clazz, String propertyName, Object value) {
   List<E> list = findByProperty(clazz, propertyName, value);
   if (Validator.isEmpty(list)) {
     return Boolean.FALSE;
   } else {
     return Boolean.TRUE;
   }
 }
Exemplo n.º 4
0
 /**
  * 判断数据库表是否存在
  *
  * @param tableName
  * @return true:存在;false:不存在
  * @author LiuKun
  * @throws SQLException
  * @created 2012-8-9 下午7:29:24
  */
 @Transactional
 public Boolean existTable(String tableName) {
   if (Validator.isEmpty(tableName)) {
     throw new RuntimeException("数据库表名为空!");
   }
   Boolean flag = Boolean.FALSE;
   try {
     flag = getBaseDao().existTable(tableName);
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
   return flag;
 }
Exemplo n.º 5
0
 /**
  * 保存实体集合
  *
  * @param entitys
  * @author LiuKun
  * @created 2012-8-2 上午9:56:27
  */
 @Transactional
 public <E extends Entity> void save(Collection<E> entitys) {
   if (Validator.isNotEmpty(entitys)) {
     baseDao.save(entitys);
   }
 }