openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bert Bee-Lindgren <bert.bee-lindg...@oit.gatech.edu>
Subject Refresh after another EM removes one-to-many member
Date Thu, 15 May 2008 21:23:13 GMT
I have two EntityManagers

EM1 has an object r1 which has a one-to-many relationship  
[CascadeType.ALL] myTees containing t1

EM2
	starts transaction
	reads r1
	removes t1 from r1.myTees
	commits transaction


When EM1 does a refresh(r1), it gets the following exception:
Caused by: <openjpa-1.0.2-r420667:627158 nonfatal store error>  
org.apache.openjpa.persistence.EntityNotFoundException: The follwing  
instnaces do not exist in the data store: [88979  
[org.apache.openjpa.util.IntId]]
	at  
org 
.apache 
.openjpa.kernel.BrokerImpl.newObjectNotFoundException(BrokerImpl.java: 
4343)
	at  
org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java: 
2796)
	... 25 more


My expectation is that r1.myTees would simply be an empty collection  
after the refresh.

An hibernate thread seemed to trace this to a cascade refresh being  
done before the relationships destinations were rebuilt.
	From http://forum.hibernate.org/viewtopic.php?t=981635&highlight=
	Looking the hibernate code (admittedly, core hibernate), the  
DefaultRefreshEventListener.onRefresh method has a call to  
evictCachedCollections but after the refresh has been cascaded to its  
children. It seems like this should happen before the refresh is  
cascaded, or at least be an option.


Am I wrong to expect refresh to work this way?
Should I always do EM1.find()?

Thanks,
   Bert

Mime
View raw message