Good morning every body,
I've a little problem with the hibernate's id managing. I've learned in the reference documentation and in a book that I'm reading that when we persist an object, hibernate will associate the resulting id to the java object (depending on the id generator used).
In my testing code I use a native generator, so when I save the object, an insert occure immediately to retrieve the id. The id is returned by the save method but normally the id is set in the java object isn't it?... In my case... nothing happen. My object is correctly persisted but it doesn't have the id set.
I read, re-read the doc, I debug my code and hibernate, I searched in the forum, in the faq, on google... I didn't find why hibernate didn't init my id... Could anyone help me please?
Thanks in advance.
Hibernate version:3.2.5
Mapping documents:
Code:
<class name="Event" table="tevent">
<id type="long">
<generator class="native" />
</id>
<property name="title" type="string" />
<many-to-one cascade="save-update" class="Speaker" column="speaker_id" name="speaker" />
</class>
Code between sessionFactory.openSession() and session.close():Code:
tr = session.beginTransaction();
session.save(e);
tr.commit();
log.debug("ID Event = "+ e.getId());
Name and version of the database you are using: MySQL 5
The generated SQL (show_sql=true): insert into tevent (title, speaker_id) values (?, ?)
Debug level Hibernate log excerpt: DEBUG