Hi,
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2
I have problem with updating my data.
I have User class that contains UserInformation. Theire are linked with one-to-one relation. When I call session.saveOrUpdate() something went wrong. (When I call only update() it dosn't solve the problem)
Data in User table are updated, but in UserInformation isn't , there is created a new row in user_information table with new primmary key.
My User mapping file contains:
Code:
<id name="id" column="user_id" unsaved-value="0">
<generator class="foreign">
<param name="property">userInformation</param>
</generator>
</id>
<one-to-one name="userInformation" class="UserInformation" cascade="all"></one-to-one>
. . .
My UserInformation mapping file contains:
Code:
<id name="id" column="user_information_id" unsaved-value="0">
<generator class="increment" />
</id>
. . .
Hibernate think that my UserInformation object wasn't save. But it was and it gets an ID.
Some logs:
DEBUG - version unsaved-value strategy NULL
DEBUG - saveOrUpdate() previously saved instance with id: 12
DEBUG - updating [webmail.model.User#12]
DEBUG - processing cascades for: webmail.model.User
DEBUG - cascading to saveOrUpdate()
DEBUG - saveOrUpdate() unsaved instance
DEBUG - fetching initial value: select max(user_information_id) from user_information
DEBUG - first free id: 20
What can I do wrong ?