|Re: [eclipselink-users] non-repeatable read in combination with a delete|
Your removeCompany code is wrong. Before removing an object you must remove any references to it. Normally you would get a constraint error, but you have the constraint defined in the other direction. If you are concerned about concurrency, then you should also be using optimistic version locking. This would allow the version of the company to be checked so that it knows it is an existing object. This is also related to your usage of registerObject instead of registerExistingObject and your does-exist policy. The default does exist is to check the cache, as it assumes the cache is correct. But your remove has corrupted the cache, you could set another type of existence check if you intend to corrupt your cache. Huub Sepers-2 wrote: > > Hi, > > > > I have a question about a non-repeatable read scenario whereby a parent > entity is deleted. > > > > See the enclosed testcase. > > > > The following scenario: > > > > We have 2 entities with a parent-child relationship, Company-Employee. > Suppose the parent is removed in one thread wile another thread inserts > a child for the same parent. > It appears that different things happen according to timing issues. > > > > It appears that when the parent is removed (commit) just after it has > been found but just before it is registered then the parent will be > inserted as a new object with the same primary key. > > See testcase "testWR". > > When the parent is removed after it has been registered an ORA-02291 > (parent key not found) will occur. > > See testcase "testWR2" > > > > The testcases are single threaded but illustrate the point. > > > > I have tested this with Eclipselink 1.1.4, 1.1.2, 1.1.1 and 1.2.0. > > > > Questions: > > I would expect the ORA-02291 to occur in both cases? > > What can I do to get a consistent error in both cases? > > > > Met vriendelijke groet, > > Huub Sepers > > Software Engineer > > > ----- http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland http://www.eclipse.org/eclipselink/ EclipseLink , http://www.oracle.com/technology/products/ias/toplink/ TopLink Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink , http://wiki.oracle.com/page/TopLink TopLink Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , http://www.nabble.com/EclipseLink-f26430.html EclipseLink Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence Blog: http://java-persistence-performance.blogspot.com/ Java Persistence Performance -- View this message in context: http://old.nabble.com/non-repeatable-read-in-combination-with-a-delete-tp30698828p30710231.html Sent from the EclipseLink - Users mailing list archive at Nabble.com.
Back to the top