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

Gail Badner (JIRA) noreply at atlassian.com
Wed Jan 11 08:47:12 EST 2012


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

Gail Badner commented on HHH-6958:
----------------------------------

Are you sure @PrePersist method is actually executed during the merge operation? My guess is that it the @PrePersist method is (correctly) executed during flush.

Is that the case?

> 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 Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.0.0.CR2, 4.0.0.Final
>         Environment: JBoss AS 7
>            Reporter: Benjamin Diedrichsen
>            Priority: Critical
>              Labels: jpa2
>
> 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