I have a data object, Person, which stores the first and last name of a person. It also has a field, long id. This ID should be auto-incremented by the DB when a person is inserted into the database, but it doesn't seem to be happening. Details below...
Hibernate version: 3
Name and version of the database you are using: HSQL
CREATE TABLE PEOPLE (PERSON_ID bigint IDENTITY, ....)
@Entity
@Table(name = "PEOPLE")
class Person {
@Id
@Column(name="PERSON_ID")
long id;
.....
}
everytime I save a Person the ID is set to 0, so I only end up with one object in the DB. Am I missing something? I should just be able to save it and the ID be incremented automatically right?
Person p = createPerson();
session.save(p);
Thanks
|