Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Failed insert results in invalid cache state

Here's my situation:

I'm trying to determine if it's possible to retry an insert when it fails
due to PK collision. (Please don't ask why, just go with it).

So i've got my own ID Generator which assigns the ID of 1 to every entity.
I've also built a ExceptionHandler to deal with the collision error.

In the error handler i've good logic to clone the failed insert object,
without the old PK. I update the ID generator's next value to 2. Then i just
re-execute the query (which assigns the new ID). 

I then execute my tests (JUnit methods), before each of them i delete the
database contents to ensure a clean slate:

1) ID Collision insert on single executable statement w/ retry disabled - #
Records in DB = 1 - Correct
2) ID Collision insert on single executable statement w/ retry enabled - #
Records in DB = 2 - Correct
3) ID Collision on 4th statement after 3 successful inserts (parent, child,
grandchild, great-grandchild<-Collision) w/retry disabled - # Of records in
DB 0 - Correct 

But if i do a "find" on the ID for the parent, i get back the failed
inserted object from test #2. The database still has 0 contents because the
whole transaction was rolled-back.

Can someone tell me why the cache has failed insert objects in it, and/or
how to clear them before i attempt my retries?

Any help is much appreciated, and my thanks in advance.

-B
-- 
View this message in context: http://www.nabble.com/Failed-insert-results-in-invalid-cache-state-tp25384148p25384148.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top