wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate, id, oracle, sequence" Watch "Hibernate, id, oracle, sequence" New topic
Author

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?)

Thanks


--BJCK--
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.
 
jQuery in Action, 2nd edition
 
subject: Hibernate, id, oracle, sequence
 
Similar Threads
Using select strategy (id generated by oracle trigger)
Trying to save the object value without using Generation Strategy ?
Insertion of objects with Sequences + Trigger
what i will use in hbm when we use sequence at backend side ?
why my oracle sequence id increases by 2 when I use hibernate to insert