[hibernate-issues] [Hibernate-JIRA] Created: (EJB-303) Removing an entity and clearing the persistence context messes up FlushMode.AUTO
Geoffrey De Smet (JIRA)
noreply at atlassian.com
Tue Jul 10 05:56:52 EDT 2007
Removing an entity and clearing the persistence context messes up FlushMode.AUTO
--------------------------------------------------------------------------------
Key: EJB-303
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-303
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.0.ga
Reporter: Geoffrey De Smet
Priority: Critical
Remove an entity, then EM.clear() before EM.flush() with FlushMode.AUTO makes next querty still contain the removed entity.
Try something like this:
public void delete(Person detachedPerson) {
int oldSize = entityManager.createQuery("select x from Person person").getResultList().size();
Person person = entityManager.merge(detachedPerson);
entityManager.remove(person);
entityManager.clear(); // causes the problem
entityManager.flush(); // probably obsolete to prove this bug
int newSize = entityManager.createQuery("select x from Person person").getResultList().size();
assertEquals(newSize, oldSize - 1); // they turn out to be still the same size
}
Not doing entityManager.clear() fixes the problem, but because I am not using an extended peristence context and my testcases run in a rollback transaction, I need to clear the entityManger after every service call (so between the service call delete and the service call findAll).
I looked through the JIRA's, but it didn't look like it's already posted.
--
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