]
Scott Marlow reassigned HHH-4880:
---------------------------------
Assignee: Gail Badner
This regression was caused by revision 18643 (DefaultRefreshEventListener). I assume the
fix would be to test if the entity exists in the database before the
"source.setReadOnly" call.
Could the "source.setReadOnly" be moved below the "!e.isExistsInDatabase()
)" test?
EntityManager.refresh does not throw EntityNotFoundException for
removed entity
-------------------------------------------------------------------------------
Key: HHH-4880
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4880
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-Beta-4
Environment: Hibernate 3.5.0-Beta-4, JBoss AS trunk (from which 6.0.0.M2 will be
released), Sun Java 1.6
Reporter: jaikiran
Assignee: Gail Badner
The EntityManager.refresh method says this:
/**
* Refresh the state of the instance from the database,
* overwriting changes made to the entity, if any.
*
* @param entity
* @throws IllegalStateException if this EntityManager has been closed
* @throws IllegalArgumentException if not an entity
* or entity is not managed
* @throws TransactionRequiredException if invoked on a
* container-managed entity manager of type
* PersistenceContextType.TRANSACTION and there
is
* no transaction.
* @throws EntityNotFoundException if the entity no longer
* exists in the database
*/
public void refresh(Object entity);
JBoss EJB3 testsuite has a testcase which currents tests that this method works as
expected
http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/testsuite/src/...
In short, the testcase does this:
MyEntity e = manager.find(MyEntity.class, id);
local.removeEntity(e.id);
try
{
manager.refresh(e);
}
catch (EntityNotFoundException e1)
{
return; // correct
}
Starting 3.5.0-beta-4 of hibernate, this test fails with the following (unexpected)
exception:
Caused by: org.hibernate.AssertionFailure: object must be non-null.
at
org.hibernate.engine.StatefulPersistenceContext.setReadOnly(StatefulPersistenceContext.java:1340)
at org.hibernate.impl.SessionImpl.setReadOnly(SessionImpl.java:1982)
at
org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:154)
at
org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:62)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:1108)
at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:1088)
at
org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:660)
at
org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:636)
at
org.jboss.jpa.impl.tx.TransactionScopedEntityManager.refresh(TransactionScopedEntityManager.java:224)
at org.jboss.ejb3.test.regression.ejbthree290.DAOBean.findAndDelete(DAOBean.java:58)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: