/** * 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; }
/** 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; }
/** Deletes a single row in the CITY table. */ public void delete(CityPk pk) throws DataBaseJdbcException { getJdbcTemplate().update("DELETE FROM " + getTableName() + " WHERE ID = ?", pk.getId()); }
/** 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()); }