[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2305) refresh throws exception when database has been altered with a delete

Chris L (JIRA) noreply at atlassian.com
Tue Sep 28 14:23:58 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38534#action_38534 ] 

Chris L commented on HHH-2305:
------------------------------

We're having the same kind of problem.  I agree with the outline of the proposed solution too: you should refresh the top level object first, and see what the Refresh should cascade to, and THEN refresh only the still-referenced objects.  For now the best workaround we've come up with is to stop deleting orphaned entities, so that they're still available in the database to be refreshed.  Messy, but at least refresh will work properly then.

> refresh throws exception when database has been altered with a delete
> ---------------------------------------------------------------------
>
>                 Key: HHH-2305
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2305
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.1
>         Environment: Hibernate 3.2.1, Oracle 9.2
>            Reporter: Markus Heiden
>         Attachments: hibernate.zip
>
>
> First I save an entity with a collection of cascading entities in it and flush. Then I delete these cascaded entities with a sql query. When I now do a refresh on the entity an exception is thrown, because the cascaded entities couldn't be found in the database. I expected these entities to be deleted from the (in memory) collection of the entity instead.
> Test case is attached. Stacktrace of test case:
> Hibernate: select c0_.id as id2_0_, c0_.c as c2_0_ from C c0_ where c0_.id=?
> org.hibernate.UnresolvableObjectException: No row with the given identifier exists: [hibernate.refresh.C#30003]
> 	at org.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:42)
> 	at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:126)
> 	at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:911)
> 	at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:894)
> 	at org.hibernate.engine.CascadingAction$4.cascade(CascadingAction.java:169)
> 	at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> 	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> 	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> 	at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> 	at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> 	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> 	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> 	at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> 	at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:99)
> 	at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:911)
> 	at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:894)
> 	at org.hibernate.engine.CascadingAction$4.cascade(CascadingAction.java:169)
> 	at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
> 	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
> 	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> 	at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:296)
> 	at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:242)
> 	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:219)
> 	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
> 	at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
> 	at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:99)
> 	at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:39)
> 	at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:902)
> 	at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:886)
> 	at hibernate.refresh.Test.main(Test.java:46)

-- 
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