コード例 #1
0
ファイル: DictKungFuTypeDAL.java プロジェクト: eiasy/DouPo
 public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
   DictKungFuType dictKungFuType = new DictKungFuType();
   dictKungFuType.setId(rs.getInt("id"), 0);
   dictKungFuType.setName(rs.getString("name"), 0);
   dictKungFuType.setSname(rs.getString("sname"), 0);
   dictKungFuType.setDescription(rs.getString("description"), 0);
   dictKungFuType.setVersion(rs.getInt("version"), 0);
   return dictKungFuType;
 }
コード例 #2
0
ファイル: DictKungFuTypeDAL.java プロジェクト: eiasy/DouPo
  public DictKungFuType add(final DictKungFuType model, int instPlayerId) throws Exception {
    try {
      StringBuilder strSql = new StringBuilder();
      strSql.append(" insert into Dict_KungFuType (");
      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.dictKungFuTypeMap.put(model.getId(), model);
      }
    } catch (Exception e) {
      throw e;
    }
    return model;
  }