[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-5124) Removing an entity and persisting it again fails

Jesper Steen Møller (JIRA) noreply at atlassian.com
Sat Apr 17 17:42:58 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5124?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Steen Møller updated HHH-5124:
-------------------------------------

    Attachment: HHH-5124.txt

I have developed a fix for this which deals with this issue, and doesn't break anything else, according to core's tests (I have not tested this with Search, Validator, etc.)

Two tests are added to capture the essence of the bug and fix:
  1) one a a simple delete() - persist() sequence (JPA 3.2.1, Persisting an Entity Instance) 
  2) another is a test where the persist is happens as part of a flush operation with cascade persist (JPA 3.2.3: Synchronization to the Database, which states that the persist operation is applied to entities Y which are reached from a relationship which is marked for cascade).

Only downside to the patch is that I had to extend the public interface of ActionQueue, but I found it impossible otherwise to undelete an entity.

The patch is against the 3.5.1 tag, but should apply against head, and likely also the 3.3 branch (http://anonsvn.jboss.org/repos/hibernate/core/tags/hibernate-3.5.1-Final)

"Be gentle, this is my first time" [submission of a patch to Hibernate, that is]

> Removing an entity and persisting it again fails
> ------------------------------------------------
>
>                 Key: HHH-5124
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5124
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.x, 3.5.x
>         Environment: Tested with Hibernate 3.3.2, HSQL 1.7.2
>            Reporter: Jesper Steen Møller
>         Attachments: HHH-5124.txt, RemoveAndPersistProblem.zip
>
>
> According to the JPA spec section 3.2.1, it should be possible to remove and then (re)persist an entity, but Hibernate will throw an javax.persistence.EntityNotFoundException: deleted entity passed to persist, originating from DefaultPersistEventListener.onPersist, in the 'default'-case of the switch for entityState.
> The code in question is not changed between 3.3.2 and 3.5.1, so it should have the same problem.
> The enclosed test project (Eclipse project format, just add all the usual jars + hsql) demonstrates the problem.
> Also see https://forum.hibernate.org/viewtopic.php?f=1&t=995703&view=previous

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