コード例 #1
0
 /**
  * Method 'insert'
  *
  * @param dto
  * @return CityPk
  */
 public CityPk insert(City dto) {
   getJdbcTemplate()
       .update(
           "INSERT INTO "
               + getTableName()
               + " ( CITY, SUMMARY, IMAGE_URL, STATE_ID ) VALUES ( ?, ?, ?, ? )",
           dto.getCityName(),
           dto.getSummary(),
           dto.getImageUrl(),
           dto.getStateId());
   CityPk pk = new CityPk();
   pk.setId(getJdbcTemplate().queryForInt("select last_insert_id()"));
   return pk;
 }
コード例 #2
0
 /** Updates a single row in the CITY table. */
 public CityPk update(CityPk pk, City dto) throws DataBaseJdbcException {
   getJdbcTemplate()
       .update(
           "UPDATE "
               + getTableName()
               + " SET ID = ?, CITY = ?, SUMMARY = ?, IMAGE_URL = ?, STATE_ID = ? WHERE ID = ?",
           dto.getId(),
           dto.getCityName(),
           dto.getSummary(),
           dto.getImageUrl(),
           dto.getStateId(),
           pk.getId());
   return pk;
 }
コード例 #3
0
 /** Deletes a single row in the CITY table. */
 public void delete(CityPk pk) throws DataBaseJdbcException {
   getJdbcTemplate().update("DELETE FROM " + getTableName() + " WHERE ID = ?", pk.getId());
 }
コード例 #4
0
 /** Returns the rows from the CITY table that matches the specified primary-key value. */
 public City findByPrimaryKey(CityPk pk) throws DataBaseJdbcException {
   return findByPrimaryKey(pk.getId());
 }