Hi,
I have a whole bunch of Java beans annotated like this with JPA:
import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id;
@Entity
public class TitleEntry extends Entry
{
private Long id;
public TitleEntry() {}
public TitleEntry(String code, String label)
{
super(code, label);
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Long getId()
{
return id;
}
protected void setId(Long id)
{
this.id = id;
}
}
The id is always generated like this for every object and seems to be working fine.
Now the problem: When I save an object in Java:
dao.save(titleEntry);
the id-property of the bean is set to a int-value, that does not correspond with the actual id. It corresponds to the hibernate_sequence (I think).
Questions:
Why?
What is hibernate_sequence anyway (can't find a decent explanation on Hibernate website)?
How can I fix it?
Cheers, B.
PS: using Java 1.6, MSSQL2005, Hibernate3