public void update(Long id, Product product) { db.executeOperation( "update products set price = ?, active = ?, description = ?, title = ? where id = ?", product.getPrice(), product.isActive(), product.getDescription(), product.getTitle(), id); }
public void insert(Product product) { product.setId( db.insert( "insert into products (price, active, description, title) values (?,?,?,?)", Arrays.asList( product.getPrice(), product.isActive(), product.getDescription(), product.getTitle()))); }
public List<Product> list() { return db.queryForList( "select * from products where active = ? order by title", ProductRepository::toProduct, true); }
public Product retrieve(long id) { return db.queryForSingle( "select * from products where id = ?", id, ProductRepository::toProduct) .orElseThrow(() -> new RequestException(404, "Order " + id + " not found")); }