Skip to main content

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

JPA and EclipseLink support three types of sequencing, all three are managed
by the database, so never generate duplicates.  TABLE uses a sequence table
in the database, database transaction prevent duplicates, IDENTITY uses
IDENTITY columns in the database, SEQUENCE uses SEQUENCE objects in the
database.



bryans wrote:
> 
> James,
>   This is a response to a previous comment you made. I had to drop this
> research for projects but now i'm back on it. I wanted to follow up with
> something you mentioned:
> 
>  (EclipseLink will never generate duplicates).
> 
> What type of ID generator are you referring to? And, how is the guarantee
> made (in a clustered environment)? I can only think of a few ways:
> 
> 1) A database table manages the sequences (select from table, auto-update
> to next value)
> 2) EclipseLink validates the value does not already exist as an ID in the
> table prior to assigning it to the object. However this doesn't guarantee
> that the ID won't be assigned by another process elsewhere, inserting into
> the same table.
> 3) In the above instance, a sequence manager manages state across all
> instance of EclipseLink in use.
> 
> 
> 
> 
> James Sutherland wrote:
>> 
>> This is pretty advanced stuff, so you may want to reconsider you reasons
>> for trying to do this in the first place.  You might want to instead
>> catch the exception in your app and retry the whole transaction, or avoid
>> having duplicate sequence numbers in the first place (EclipseLink will
>> never generate duplicates).
>> 
>> To get your exception handler to work, you can't create a copy, as it
>> violates object identity.  You need to reset the object's pk to null. 
>> You could use the descriptor to do this generically.
>> 
>> 
>> Object value = builder.getSequenceMapping().getAttributeValue(null,
>> session);
>> builder.getSequenceMapping().setAttributeValueInObject(dup, value);
>> 
>> 
> 
> 


-----
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 
-- 
View this message in context: http://old.nabble.com/Failed-insert-results-in-invalid-cache-state-tp25384148p26498445.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top