Пример #1
0
 public DictFireSkillQuality update(DictFireSkillQuality model, int instPlayerId)
     throws Exception {
   try {
     Object[] params = null;
     int version = model.getVersion() + 1;
     StringBuffer sql = new StringBuffer("update Dict_FireSkillQuality set ");
     sql.append("name=?,sname=?,description=?,version=? ");
     sql.append("where id=? and version=?");
     params =
         new Object[] {
           model.getName(),
           model.getSname(),
           model.getDescription(),
           version,
           model.getId(),
           model.getVersion()
         };
     int count = this.getJdbcTemplate().update(sql.toString(), params);
     if (count == 0) {
       throw new Exception("Concurrent Exception");
     } else {
       model.setVersion(version, 0);
       PlayerMemObj playerMemObj = getPlayerMemObjByPlayerId(instPlayerId);
       if (instPlayerId != 0 && isUseCach() && playerMemObj != null) {
         playerMemObj.dictFireSkillQualityMap.put(model.getId(), model);
       }
     }
   } catch (Exception e) {
     throw e;
   }
   return model;
 }
Пример #2
0
 public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
   DictFireSkillQuality dictFireSkillQuality = new DictFireSkillQuality();
   dictFireSkillQuality.setId(rs.getInt("id"), 0);
   dictFireSkillQuality.setName(rs.getString("name"), 0);
   dictFireSkillQuality.setSname(rs.getString("sname"), 0);
   dictFireSkillQuality.setDescription(rs.getString("description"), 0);
   dictFireSkillQuality.setVersion(rs.getInt("version"), 0);
   return dictFireSkillQuality;
 }
Пример #3
0
  public DictFireSkillQuality add(final DictFireSkillQuality model, int instPlayerId)
      throws Exception {
    try {
      StringBuilder strSql = new StringBuilder();
      strSql.append(" insert into Dict_FireSkillQuality (");
      strSql.append("name,sname,description,version");
      strSql.append(" )");
      strSql.append(" values (?,?,?,?) ");

      final String sql = strSql.toString();
      KeyHolder keyHolder = new GeneratedKeyHolder();

      this.getJdbcTemplate()
          .update(
              new PreparedStatementCreator() {
                public PreparedStatement createPreparedStatement(Connection conn)
                    throws SQLException {
                  PreparedStatement ps = conn.prepareStatement(sql);
                  ps.setString(1, model.getName());
                  ps.setString(2, model.getSname());
                  ps.setString(3, model.getDescription());
                  ps.setInt(4, 0);
                  return ps;
                }
              },
              keyHolder);

      model.setId(keyHolder.getKey().intValue());
      model.setVersion(0);
      PlayerMemObj playerMemObj = getPlayerMemObjByPlayerId(instPlayerId);
      if (instPlayerId != 0 && isUseCach() && playerMemObj != null) {
        playerMemObj.dictFireSkillQualityMap.put(model.getId(), model);
      }
    } catch (Exception e) {
      throw e;
    }
    return model;
  }