You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception in thread "main" org.sql2o.Sql2oException: Keys were not fetched from database. Please set the returnGeneratedKeys parameter in the createQuery() method to enable fetching of generated keys.
at org.sql2o.Connection.getKey(Connection.java:190)
at com.hellokaton.anima.core.AnimaQuery.save(AnimaQuery.java:1241)
at com.hellokaton.anima.Model.save(Model.java:28)
My Postgresql database DDL:
CREATE TABLE users (
id serial PRIMARY KEY,
user_name varchar(100) NOT NULL,
age int8 NULL,
);
My Java code:
Anima db = Anima.open("jdbc:postgresql://127.0.0.1/db", "user", "pass");
User u = new User();
u.setAge(22);
u.setUserName("pero");
u.save();
@Data
@Table(name = "users", pk = "id")
public class User extends Model {
private Integer id;
private String userName;
private Integer age;
}
I found soulution:
Anima db = Anima.open("jdbc:postgresql://127.0.0.1/db", "user", "pass, new PostgresQuirks() {
@Override
public boolean returnGeneratedKeysByDefault() {
return true;
}
});
but then u.getId() return null
The text was updated successfully, but these errors were encountered:
jankod
changed the title
Got Keys were not fetched from database
Got Keys were not fetched from database, Postgresql
Aug 18, 2022
Exception in thread "main" org.sql2o.Sql2oException: Keys were not fetched from database. Please set the returnGeneratedKeys parameter in the createQuery() method to enable fetching of generated keys.
at org.sql2o.Connection.getKey(Connection.java:190)
at com.hellokaton.anima.core.AnimaQuery.save(AnimaQuery.java:1241)
at com.hellokaton.anima.Model.save(Model.java:28)
My Postgresql database DDL:
My Java code:
I found soulution:
but then u.getId() return null
The text was updated successfully, but these errors were encountered: