Auto generated primary keys with Hibernate
728959Oct 21 2009 — edited Oct 21 2009Hello 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?