[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1280) Cascade refresh and new instances
Alexey Shakov (JIRA)
noreply at atlassian.com
Thu Mar 19 07:03:39 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32677#action_32677 ]
Alexey Shakov commented on HHH-1280:
------------------------------------
Hi,
another solution (using RefreshEventListener):
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.event.RefreshEvent;
import org.hibernate.event.def.DefaultRefreshEventListener;
@SuppressWarnings("serial")
public class RefreshListener extends DefaultRefreshEventListener {
private static final Log log = LogFactory.getLog(RefreshListener.class);
@SuppressWarnings("unchecked")
@Override
/**
* This implementation throws no exception, if non-persistent object is refreshed
*/
public void onRefresh(RefreshEvent event, Map refreshedAlready) throws HibernateException {
if (event.getSession().contains(event.getObject())) super.onRefresh(event, refreshedAlready);
else log.info("Object " + event.getObject() + " was probably not persisted yet");
}
}
SessionFactory configuraton (Spring):
<property name="eventListeners">
<map>
<entry key="refresh"><bean class="...RefreshListener" /></entry>
</map>
</property>
> Cascade refresh and new instances
> ---------------------------------
>
> Key: HHH-1280
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1280
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Reporter: Gavin King
> Attachments: Fix.zip, patch.zip
>
>
> I have a report that if you have a managed object, with a reference to a new object, where cascade refresh is enabled, and you refresh the managed object, then you will get an exception as refresh tries to cascade to the new object. In fact, the new object should just be ignored.
> Looking at the code, this does appear to be the case.
--
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