|
Change By:
|
Brett Meyer
(31/Oct/12 12:45 PM)
|
Description:
|
Hello there,
I think saveOrUpdate() behaves somewhat unexpected for associations with delete-orphan cascading style:
Prerequisite: Association is set to cascade="all,delete-orphan" and nullable=true
1) Within a single session (i.e. a transient object): * Load parent * Delete child * saveOrUpdate() Result: Child is deleted from DB, a DELETE statement was issued
2) Across multiple session (i.e. a detached object): * Have parent with valid ID, but empty list/set of children * saveOrUpdate() Result: Child is not deleted from DB, an UPDATE statement is issued which sets FK of child to 'null'
3) like 2) but nullable is FALSE Result: Nothing happens.
With merge() everything works as expected for detached and transient instances. I would
either
expect saveOrUpdate()
to completely disregard DELETE statements OR
behave similar to merge().
At least the different results of case 1) and 2) are pretty confusing.
Best regards,
Fabian
|
Environment:
|
Hibernate 3.2.6.GA, PostgreSQL 8.3
|
Affects Version/s:
|
4.1.7
|
Summary:
|
Unexpected behaviour of saveOrUpdate() for
Support
associations
with
delete-orphan
on saveOrUpdate()
|
|
|