@Override public boolean insert(Connection connection, Category category) throws SQLException { Integer newId = insertQuery(connection, SQL_INSERT_QUERY, category.getName(), category.getImageUrl()); setId(category, newId); return newId != null; }
@Override public List<Category> select(Connection connection, String query, Object... args) throws SQLException { List<Category> categories = new ArrayList<>(); ResultSet rs = selectQuery(connection, query, args); Category category; while (rs.next()) { category = ENTITY_FACTORY.createCategory(); setId(category, rs.getInt("id")); category.setName(rs.getString("name")); category.setImageUrl(rs.getString("image_url")); categories.add(SynchronizedWrapperUtils.wrap(category)); } return categories; }
@Override public boolean update(Connection connection, int id, Category category) throws SQLException { return changeQuery( connection, SQL_UPDATE_QUERY, category.getName(), category.getImageUrl(), id); }