File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate, id, oracle, sequence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate, id, oracle, sequence" Watch "Hibernate, id, oracle, sequence" New topic

Hibernate, id, oracle, sequence

Bruno Frascino
Ranch Hand

Joined: Jul 22, 2003
Posts: 55
Hello there,

My database is Oracle, and my id column value is an Oracle sequence, this sequence is executed by a trigger, so, before each row is inserted this trigger use this sequence to get the id value. So I am confused in which id strategy generation should I define in my entity class.

1 - native
2 - sequence (oracle sequence name, or let hibernate do it?)


Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Hello Bruno,

Here's something you could try. The id value is being inserted by the trigger for you so in my opinion you do not have to specify andy Generation strategy for your Id column. I suggest you set the updateable=false and insertable=false for the id column. You should be able to specify that either in the xml file or using @Column annotation.

Shailesh Kini.
I agree. Here's the link:
subject: Hibernate, id, oracle, sequence
Similar Threads
Insertion of objects with Sequences + Trigger
Trying to save the object value without using Generation Strategy ?
why my oracle sequence id increases by 2 when I use hibernate to insert
Using select strategy (id generated by oracle trigger)
what i will use in hbm when we use sequence at backend side ?