refresh() throws entity not managed exception
---------------------------------------------
Key: EJB-273
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-273
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.1
Reporter: Charles Canning
Priority: Critical
When you call EntityManager.refresh() to reattach an entity to the entitymanager, it
throws:
java.lang.IllegalArgumentException: Entity not managed
at
org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:260)
The code is:
public void refresh(Object entity) {
checkTransactionNeeded();
//adjustFlushMode();
try {
if ( ! getSession().contains( entity ) ) {
throw new IllegalArgumentException( "Entity not managed" );
}
getSession().refresh( entity );
}
catch (MappingException e) {
throw new IllegalArgumentException( e.getMessage(), e );
}
catch (HibernateException he) {
throwPersistenceException( he );
}
}
It is checking if the object is already in the session - this will not allow me to
reattach. If I "cast" the EM to the session delegate, refresh works fine because
it doesn't contain this check.
For more info, you can look at this forum topic :
http://forum.hibernate.org/viewtopic.php?t=971661&start=0&postday...
--
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