I have a setup with Oracle XE 10g, Hibernate 3.5, JPA 2.0. There is a simple table with a primary key, which is generated by a database trigger at insertion. The trigger gets the value from a sequence. The trigger/sequence construction was made by Oracle XE.
The actual question is: How do I get the current value of the Id in my entity after a EntityManager.persist?
I tried:
@Id
private long id;
-> id is 0
;
@Id
@Generated(GenerationTime.ALWAYS)
@Column(insertable = false, updatable = false)
private long id;
-> id is 0
;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
-> Fails because Hibernate is trying to query the a sequence directly (which does not exist).
IDs are generated in the database in the first two approaches, but I don't have the value in my object.