[jboss-user] [EJB 3.0] - find throwing EntityNotFoundException?
mazz@jboss.com
do-not-reply at jboss.com
Sun May 6 18:54:18 EDT 2007
EntityManager.find() is supposed to return null when the entity is not in the DB.
This works except under this condition. I'm seeing this in a unit test of mine, hence the odd use-case (I'm deleting the resource and then immediately trying to find it again), but it does seem like its not behaving properly in that case.
Do this to replicate:
Pojo pojo = new Pojo();
| entityManager.persist(pojo);
| int id = pojo.getId();
| entityManager.remove(pojo);
| assert entityManager.find(Pojo.class, id) == null; // this throws exception
find() should return null in this case, but I get this exception:
javax.persistence.EntityNotFoundException: org.hibernate.ObjectDeletedException: The object with that id was deleted: [Pojo#506554]
| at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:564)
| at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:168)
| ...
I was wondering if anyone else sees this, and if its truly the way its designed to work. Again, it is an odd use case and one I'm only using in a unit test so I'm not worried about it. Wasn't sure if I should JIRA this or not.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043551#4043551
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043551
More information about the jboss-user
mailing list