[
http://opensource.atlassian.com/projects/hibernate/browse/EJB-98?page=all ]
Emmanuel Bernard resolved EJB-98:
---------------------------------
Resolution: Fixed
Assign To: Emmanuel Bernard
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
Assignee: Emmanuel Bernard
Fix For: 3.2.0.cr2
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira