[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
Fri Jan 13 05:02:09 EST 2012


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

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

I can't tell exactly at what time the @PrePersist is called. The thing is that, according to my understanding of the spec, it should not be called at any time, since the object is not persisted or merged. The PrePersist method is called on object c but no insert or update query is executed (I checked the jpql output).

> 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
>            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