コード例 #1
0
ファイル: DictKungFuTypeDAL.java プロジェクト: eiasy/DouPo
 @SuppressWarnings("unchecked")
 public DictKungFuType getModel(int id, int instPlayerId) {
   try {
     PlayerMemObj playerMemObj = getPlayerMemObjByPlayerId(instPlayerId);
     if (instPlayerId != 0 && isUseCach() && playerMemObj != null) {
       DictKungFuType model = playerMemObj.dictKungFuTypeMap.get(id);
       if (model == null) {
         String sql = "select * from Dict_KungFuType where id=?";
         Object[] params = new Object[] {id};
         playerMemObj.dictKungFuTypeMap.put(
             id,
             (DictKungFuType)
                 this.getJdbcTemplate().queryForObject(sql, params, new ItemMapper()));
       } else {
         int cacheVersion = model.getVersion();
         List<Map<String, Object>> list =
             sqlHelper("select version from Dict_KungFuType where id = " + id);
         int dbVersion = (int) list.get(0).get("version");
         if (cacheVersion != dbVersion) {
           String sql = "select * from Dict_KungFuType where id=?";
           Object[] params = new Object[] {id};
           playerMemObj.dictKungFuTypeMap.put(
               id,
               (DictKungFuType)
                   this.getJdbcTemplate().queryForObject(sql, params, new ItemMapper()));
         }
       }
       model = playerMemObj.dictKungFuTypeMap.get(id);
       model.result = "";
       return model;
     } else {
       String sql = "select * from Dict_KungFuType where id=?";
       Object[] params = new Object[] {id};
       DictKungFuType model =
           (DictKungFuType) this.getJdbcTemplate().queryForObject(sql, params, new ItemMapper());
       model.result = "";
       return model;
     }
   } catch (DataAccessException e) {
     return null;
   }
 }
コード例 #2
0
ファイル: DictKungFuTypeDAL.java プロジェクト: eiasy/DouPo
 private List<DictKungFuType> listCacheCommonHandler(String sql, int instPlayerId) {
   List<DictKungFuType> modelList = new ArrayList<DictKungFuType>();
   PlayerMemObj playerMemObj = getPlayerMemObjByPlayerId(instPlayerId);
   SqlRowSet rsSet = this.getJdbcTemplate().queryForRowSet(sql.toString());
   while (rsSet.next()) {
     int id = rsSet.getInt("id");
     int dbVersion = rsSet.getInt("version");
     DictKungFuType model = playerMemObj.dictKungFuTypeMap.get(id);
     if (model == null) {
       model = getModel(id, instPlayerId);
       model.result = "";
       modelList.add(model);
     } else {
       int cacheVersion = model.getVersion();
       if (cacheVersion != dbVersion) {
         model = getModel(id, instPlayerId);
       }
       model.result = "";
       modelList.add(model);
     }
   }
   return modelList;
 }