[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-409) EAGER fetched collection + Cascade.PERSIST generates broken behavior on session.update
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Fri Jan 16 07:59:38 EST 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32147#action_32147 ]
Hardy Ferentschik commented on EJB-409:
---------------------------------------
Hi,
maybe I was not clear enough. I know in your example you are not calling persist() explicitly, however it is called implicitly due to the transaction commit. The cited section comes from section 3.2.3 of the specification - "The state of persistent entities is synchronized to the database at transaction commit. This synchronization involving writing to the database any updates to persistent entities and their relationships as specified above."
So really, your problem is not the update as such, but the final commit and what it implies in a JPA context. You seem to expect that CascadeType.PERSIST in JPA behaves like saveOrUpdate in Hibernate, but that is not the case.
> EAGER fetched collection + Cascade.PERSIST generates broken behavior on session.update
> --------------------------------------------------------------------------------------
>
> Key: EJB-409
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-409
> Project: Hibernate Entity Manager
> Issue Type: Bug
> Affects Versions: 3.2.1
> Reporter: Anthony Patricio
> Attachments: HBCoreTestCase.zip, HEMTestCase.zip
>
>
> I didn't really know where to log this extremely weird bug.
> Customer 1--* Contact
> Bidirectional.
> Collection annotated with
> @OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
> @Cascade({CascadeType.PERSIST})
> Step 1: load a Customer (contacts are transparently retrieved) and detach the graph.
> Step 2: re attach using session.update
> --> session tries to insert into CONTACT table
> Weird things:
> - works with @OneToMany(fetch=FetchType.LAZY, mappedBy="customer")
> - works if CascadeType.PERSIST is removed
> - works with 100% plain hibernate (mapping files + session APIs (via session Factory, see test based on hb core template)
> - fails with 50% plain hibernate (mapping files + EM APIs to obtain HB session)
> - I also tried to use HEM + hb plain mapping files --> this is failing, that's why I raised the issue in HEM project.
> I'm attaching 2 testcases: one using HEM test template (failing test) and one using HB Core template (passing test).
> This use case is not so exotic and the problem may hide something more critical.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list