This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Using select strategy (id generated by oracle trigger) 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 "Using select strategy (id generated by oracle trigger)" Watch "Using select strategy (id generated by oracle trigger)" New topic
Author

Using select strategy (id generated by oracle trigger)

Michael Houlo
Ranch Hand

Joined: Jun 07, 2010
Posts: 58
Dear,

My bean id is generated by an oracle sequence which is incremented and affected by a trigger.
I have to specify it in my bean, i see a lot of example on internet, but always with xml files... I'm using annotations..

Here is what i tryed :

I have an unknown property "TAB_ID"

If i disable the oracle trigger and use this following code, it works.. Hibernate will manage the sequence, but that's not what i want..


Since the bean doesn't know the id is managed by oracle, when i do "save(myObj)", the record is correctly inserted, but the id returned is "0" ..
Furthermore, when i use saveOrUpdate(myObj), even if the id already exist (i'm updating an existing record), hibernate will insert a new record instead of updating the existing one...

Could you tell me how to do ?
Thanks a lot !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using select strategy (id generated by oracle trigger)
 
Similar Threads
ORA-02291: integrity constraint, can not find parent key
identity columns as generators
Using Oracle sequence with JBOSS
Error in generating Sequence
Problem whne used custom squence name in JPA (hibernate) annotations