[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-98) EntityManager.find() throws an org.hibernate.ObjectDeletedException if you find something deleted in the same TXA

Michał Borowiecki (JIRA) noreply at atlassian.com
Tue Aug 22 18:21:19 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-98?page=comments#action_24032 ] 

Michał Borowiecki commented on EJB-98:
--------------------------------------

I think this issue was fixed with HHH-1818.  Can you run your test case on the latest sources to verify?

> EntityManager.find() throws an org.hibernate.ObjectDeletedException if you find something deleted in the same TXA
> -----------------------------------------------------------------------------------------------------------------
>
>          Key: EJB-98
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-98
>      Project: Hibernate Entity Manager
>         Type: Bug

>   Components: EntityManager
>     Versions: 3.1beta5
>  Environment: Java 1.5.06/junit3.8.1,hibernate 3.1, entity manager 3.1beta5, hsqldb 1.8.01
>     Reporter: Steve Loughran
>      Fix For: 3.2.0
>  Attachments: DefaultLoadEventListener.patch
>
>
> I have a junit test case that persists something, finds it, then deletes it and tries to find again.
> Second time round, find() fails with an ObjectDeletedException. This is the semantics of Session.load(), not EntityManager.find(), which is meant to return null if something cannot be found:
>     public void testDeleteAndFindFailsWrong() throws Exception {
>         Event event = createTestEvent();
>         String key = event.getKey();
>         EntityTransaction transaction = null;
>         try {
>             transaction = manager.getTransaction();
>             transaction.begin();
>             manager.persist(event);
>             Event e2 = manager.find(Event.class, key);
>             assertEquals(event, e2);
>             manager.remove(e2);
>             try {
>                 e2 = manager.find(Event.class, key);
>                 assertNull("The spec says that find should return null here", e2);
>             } catch (ObjectDeletedException e) {
>                 fail("This is not in the spec"+e);
>             }
>         } finally {
>             rollback(transaction);
>         }
>     }   

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