]
Alex K commented on HHH-3064:
-----------------------------
I have run into the same issue. It appears to be a regression from the earlier fix
(HHH-1401).
unnecessary update when merge managed entity
--------------------------------------------
Key: HHH-3064
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3064
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Hibernate Core 3.2.5.ga
Hibernate Annotations 3.3.0 GA
hsqldb
Reporter: Jifeng Liu
Attachments: testcase.zip
If the entity in em.merge(entity) is managed entity, the merge operation should be
ignored. However it issues a update statement in the test case even if there is no
changes.
In the test case, Parent entity has a list of Image entity with Many-To-Many relation.
em.merge() somehow marks the list as dirty, which causes the update statement.
The following is trace log of the test case.
07.20,23 INFO ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
07.20,601 DEBUG SQL - /* insert test.Parent */ insert into Parent (updateDateTime,
Parent_No) values (?, ?)
07.20,617 DEBUG SQL - /* insert test.Image */ insert into Image (name, imageNo) values
(?, ?)
07.20,617 DEBUG SQL - /* insert collection row test.Parent.images */ insert into
Parent_Image (Parent_Parent_No, images_
imageNo) values (?, ?)
07.20,632 DEBUG SQL - /* load test.Parent */ select parent0_.Parent_No as Parent1_0_0_,
parent0_.updateDateTime as updat
eDa2_0_0_ from Parent parent0_ where parent0_.Parent_No=?
07.20,648 DEBUG SQL - /* load collection test.Parent.images */ select
images0_.Parent_Parent_No as Parent1_1_, images0_.
images_imageNo as images2_1_, image1_.imageNo as imageNo1_0_, image1_.name as name1_0_
from Parent_Image images0_ left o
uter join Image image1_ on images0_.images_imageNo=image1_.imageNo where
images0_.Parent_Parent_No=?
07.20,679 DEBUG SQL - /* update test.Parent */ update Parent set updateDateTime=? where
Parent_No=? and updateDateTime=?
07.20,679 DEBUG SQL - /* delete collection test.Parent.images */ delete from Parent_Image
where Parent_Parent_No=?
07.20,679 DEBUG SQL - /* insert collection row test.Parent.images */ insert into
Parent_Image (Parent_Parent_No, images_
imageNo) values (?, ?)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: