[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2146) NullpointerException in DefaultDeleteEventListener.deleteTransientEntity

Gail Badner (JIRA) noreply at atlassian.com
Wed Feb 13 18:56:34 EST 2008


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

Gail Badner commented on HHH-2146:
----------------------------------

I ran into this very same issue yesterday when trying to delete a detached object that had been modified to include a transient entity.

The workaround is to first merge the detached entity into the session, then delete the entity now cached in the session, as follows:

Entity mergedEntity = (Entity) session.merge( entity );
session.delete( mergedEntity );

Be sure to delete the entity that is returned by session.merge( entity ), not the original entity; otherwise, NonUniqueObjectException will be thrown.

In the test case provided by Donnchadh, using session.merge( page ) instead of session.save( page ) will work.

> NullpointerException in DefaultDeleteEventListener.deleteTransientEntity
> ------------------------------------------------------------------------
>
>                 Key: HHH-2146
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2146
>             Project: Hibernate3
>          Issue Type: Bug
>    Affects Versions: 3.2.0.cr5
>         Environment: Hibernate 3.2.0cr5, Oracle10g
>            Reporter: Martin Kartumovich
>            Priority: Minor
>         Attachments: Cascade.java, deletetransientmn.zip
>
>
> The following setup leads to a NPE in DefaultDeleteEventListener.deleteTransientEntity:
> Tables A, B
> Table V_A_B that is an M-N-Connection between A and B.
> Pojo for A has a Set of V_A_Bs.
> Pojo for B has a Set of V_A_Bs.
> Pojo C that has Sets of As and Bs.
> Cascades: all, delete-orphan
> -Create a new A and add a new V_A_B to its Set, that references to an existing B.
> -Delete B.
> -SaveOrUpdate Pojo C.
> In Hibernate 3.1.3 this works fine.
> In 3.2.0cr4+cr5 the removal of B results into an cascading removal of the never persisted V_A_B in the Set of B instead of ignoring it.
> This leads to an incorrect state where deleteTransientEntity is called with transientEnties=null.
> When now calling transientEnties.contains(...) the NPE is thrown.

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