I'm retrieving an object(User) and it's one-one association(Profile) from database, updating Profile (description attribute).
Try to save updated object using session.saveOrUpdate(user).
This throws constraint violation exception; this is because it's trying to INSERT new record into PROFILE table instead of UPDATE.
Mapping file looks like:
*************
<hibernate-mapping>
<class name="User" table="USER" lazy="false">
...............................................
<one-to-one name="profile" class="Profile" cascade="save-update,lock" lazy="no-proxy" access="field"/>
</class>
</hibernate-mapping>
Mapping file looks like:
*************
Thanks.
|