Example #1
0
 /**
  * 将Map对象插入数据库
  *
  * @throws AttributeException
  * @throws InvokeException
  * @throws SQLException
  * @throws DbPropertyException
  */
 public Integer insert()
     throws InvokeException, AttributeException, DbPropertyException, SQLException {
   List<String> keyList = this.getKeys();
   Map<String, Object> valueMap = super.getMap();
   for (String str : keyList) {
     if (super.getMap().get(str) == null) {
       super.getMap().put(str, StringUtil.getUUID());
     }
   }
   BuildSql buildSql = new BuildSql();
   String tableName = getMapTableName();
   buildSql.setValueMap(getMapValuesMap());
   buildSql.setTableName(tableName);
   buildSql.BuildInsertSql();
   DbCon db = new DbCon();
   return db.updateSql(buildSql);
 }
Example #2
0
 /**
  * 查询满足bean对象主键值的集合
  *
  * @return
  * @throws InvokeException
  * @throws AttributeException
  * @throws DbPropertyException
  * @throws SQLException
  */
 public List<Map<String, Object>> query()
     throws InvokeException, AttributeException, DbPropertyException, SQLException {
   String tableName = getMapTableName();
   List<String> keyList = super.getKeys();
   List<String> excluList = super.getExclusiveList();
   List<String> likeFilterCol = super.getLikeFilterCol();
   Map<String, String> mappingMap = super.getMappingMap();
   BuildSql buildSql = new BuildSql();
   List<String> colList = new ArrayList<String>();
   Map<String, Object> filteMap = new HashMap<String, Object>();
   Map<String, String> likeFilterMap = new HashMap<String, String>(); // 模糊查询对象
   Iterator<String> it = super.getMap().keySet().iterator();
   while (it.hasNext()) {
     String fieldName = it.next();
     String name = fieldName;
     Object value = super.getMap().get(fieldName);
     if (!excluList.contains(fieldName)) { // 如果不在排除列中
       if (mappingMap.containsKey(fieldName)) { // 如果存在映射关系
         name = mappingMap.get(fieldName);
       }
       //				colList.add(name) ;
       if (likeFilterCol.contains(fieldName)) {
         if (value != null) {
           likeFilterMap.put(name, StringUtil.objectToString(value));
         }
       } else if (keyList.contains(fieldName)) {
         if (value != null) {
           filteMap.put(name, value);
         }
       }
     }
   }
   if (colList.size() > 0) {
     buildSql.setColList(colList);
   }
   buildSql.setTableName(tableName);
   buildSql.setFilterMap(filteMap);
   buildSql.setLikeFilterMap(likeFilterMap);
   buildSql.setOrderList(super.getOrderList());
   buildSql.BuildQuerySql();
   DbCon db = new DbCon();
   return db.querySql(buildSql);
 }