Hibernate version: 2.1.6
Mapping documents:
from User:
Code:
<set name="reviewers" lazy="false" inverse="true" cascade="all-delete-orphan">
<key>
<column name="USER_ID"/>
</key>
<one-to-many
class="tess.Reviewer"
/>
</set>
<set name="reviewing" inverse="true">
<key>
<column name="USER_ID" />
</key>
<one-to-many class="tess.Reviewer"/>
</set>
from Reviewer:Code:
<composite-id>
<key-many-to-one name="user"
class="tess.User" column="USER_ID"/>
<key-many-to-one name="reviewer"
class="tess.UserProfile" column="REVIEWER_ID"/>
</composite-id>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Hibernate: update USER set NAME=? where USER_ID=?
Hibernate: update REVIEWER set TYPE=? where USER_ID=? and REVIEWER_ID=?
Debug level Hibernate log excerpt:
i have a relationship where someone generating reports can have a reviewer for that report. there are different types of reports, and the user can have a different reviewer for each type (or none)
the thing i am seeing is when i first add a reviewer (by adding to the set in the java object), the sql generated does an update instead of an insert.
so i am wondering how hibernate does this. assuming i have a java.util.Set of reviewers, and i add some, remove some, and modify some, when i saveOrUpdate the user how does hibernate know which ones need inseting/deleting/updating?