[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6958) PrePersist is called on object although no merge/persist operation is cascaded/applied

Benjamin Diedrichsen (JIRA) noreply at atlassian.com
Tue Jan 17 12:06:11 EST 2012


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45158#comment-45158 ] 

Benjamin Diedrichsen commented on HHH-6958:
-------------------------------------------

Hmmm, that is very strange. Looks like I have to go over our code again (we do some things around the entity manager of course), that's why it was kind of difficult to isolate the test. Thanks for your help so far. I might report back...

> PrePersist is called on object although no merge/persist operation is cascaded/applied
> --------------------------------------------------------------------------------------
>
>                 Key: HHH-6958
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6958
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.0.0.CR2, 4.0.0.Final
>         Environment: JBoss AS 7
>            Reporter: Benjamin Diedrichsen
>            Assignee: Gail Badner
>            Priority: Critical
>              Labels: jpa2
>         Attachments: PrePersistBugNewTest.java, PrePersistBugTest.java
>
>
> The scenario: A persistent instance of class A is loaded. A transient object of type b is created and with it a transient object of type c. Then the merge operation is invoked on A.
> The unexpected behaviour now is that the @PrePersist method on C is called although the causing merge-operation does not apply (not cascaded from B to C) and is actually not executed on the object (--> C will not be persisted to the database).
> Why is PrePersist invoked for C if no persist or merge operation is actually cascaded?
> Class A{
> @OneToOne(cascade = CascadeType.ALL, optional = true, orphanRemoval = true)
> private B b;
> }
> Class B{
> @ManyToOne(optional = false, cascade={CascadeType.PERSIST})
> 	private C c;
> }
> Class C{
> // some basic attributes here
> }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list