Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Auto generated primary keys with Hibernate

728959Oct 21 2009 — edited Oct 21 2009
Hello folks,

this is a question that mixes a bit of PL/SQL and a bit of Hibernate. hope this is the right forum. I am a beginner with both Oracle and Hibernate as well, so please be patient if my questions are a bit trivial.

Our application uses Hibernate as an ORM framework.

Now, I am writing a stored procedure to migrate data in my Oracle DB. My concern regards the auto-generation of primary keys in the tables, when inserting a new record.

The tables' primary keys don't have the auto_increment property. Moreover, I can see a sequence defined as

create sequence hibernate_sequence;

Thus, I was thinking of asking the next ID to this squence.

However, Hibernate uses a directive like the following:

+<id name="id" column="ID" type="long">+
+<generator class="native"></generator>+
+</id>+

I am a bit confused, since I expected that Hibernate should use the <generator class="sequence"> instead. I am afraid that the DB may use another method to update the ID.

Hence I am not sure any more that asking for the ID to the sequence is correct.

Please, can you clarify this to me?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2009
Added on Oct 21 2009
2 comments
854 views