I am trying out this library so this most likely a silly mistake on my part.
Here is my in memory Apache Derby table :
String sql="CREATE TABLE Author ("
+ "author_id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),"
+ "first_name VARCHAR(40),"
+ "last_name VARCHAR(40) "
//+ "PRIMARY_KEY(author_id)"
+ ")";
Here is the code I am using. It does a simple update with a where clause:
public void update(Author entity) {
String sql="UPDATE author SET first_name=:firstName ,last_name=:lastName WHERE author_id = :authorId";
Long id=entity.getAuthorId();
log.debug("id="+id );
try (Connection con = sql2o.open()) {
int rows=con.createQuery(sql)
.addParameter("authorId", id )
.addParameter("firstName", entity.getFirstName() )
.addParameter("lastName", entity.getLastName() )
.executeUpdate()
.getResult();
log.debug("rows="+rows);
}
}