It seems I can't convince the @Id column to autogenerate keys. I have a H2 database in server mode with a fairly simple table:
CREATE TABLE AWAY.Users (
ID INT PRIMARY KEY,
NAME VARCHAR(255),
PWDHASH INT
)
But whatever I try, EBean wants to persist only the name and the pwdhash, and "forgets" the id:
Exception in thread "main" javax.persistence.PersistenceException: org.h2.jdbc.JdbcSQLException: NULL not allowed for column ID; SQL statement:
insert into Away.Users (pwdhash, name) values (?, ?) [90006-114]
Here is my Scala class:
@Entity
@Table{val name="Away.Users"}
@BeanProperty //with and without (it generated getters and setters)
class User {
@Id
@GeneratedValue //with and without
var id:java.lang.Integer = 0 //or with Int
var name:String = ""
var pwdhash:Int = 0
}
The id column gets persisted when I don't have an @Id on it, but of course it doesn't it genereates new ones, so I get a duplicate key for the second user...
Any ideas???
Thanks,
Landei