Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » sequence getting out of sync summary
sequence getting out of sync summary [message #506950] Mon, 11 January 2010 13:30 Go to next message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
I have the impression that if one posts too many messages, they are not
read. So therefore a summary:

Sequences done with a table (@TableGenerator) can get out of sync if
JOIN_EXISTING_TRANSACTION is set to true.

With this setting, all SQL is done via the same connection; both entity
SQL and sequence table SQL. If during the database interaction a
database exception occurs (e.g. not null constraint), all updates are
rolled back, including changes to the sequence table. A sequence that
was increases is rolled back, but the value remains assigned to the
entity in memory.

In a second store attempt (after the reason of the exception was
removed) all is stored without error. However, because the entity
already had a PK assigned from the previous attempt, the sequence is not
incremented this time. This results in the situation where entities are
stored with a PK higher than the current value of the sequence.

When a new entity is stored, an exception will be thrown because of
duplicate keys.

The essence of the problem is that sequences can hand out the same value
multiple times. If @TableGenerator is emulating database sequences, then
that should not happen and would mean that sequence table SQL should
ALWAYS be done through its own connection, committed immediately, and
not be influenced by JOIN_EXISTING_TRANSACTION.

The only workaround, if using JOIN_EXISTING_TRANSACTION is a must, is to
use real database sequences. For more detail see the "sequence getting
out of sync" thread.

Tom
Re: sequence getting out of sync summary [message #506966 is a reply to message #506950] Mon, 11 January 2010 09:57 Go to previous messageGo to next message
Doug Clarke is currently offline Doug ClarkeFriend
Messages: 155
Registered: July 2009
Senior Member
Tom,

Thanks for the summary. Have you filed a bug with this summary?

Doug
Re: sequence getting out of sync summary [message #506974 is a reply to message #506966] Mon, 11 January 2010 15:12 Go to previous message
Tom Eugelink is currently offline Tom EugelinkFriend
Messages: 817
Registered: July 2009
Senior Member
On 2010-01-11 10:57, Doug Clarke wrote:
> Tom,
>
> Thanks for the summary. Have you filed a bug with this summary?
>
> Doug

I have now

Bug 299285 has been added to the database

James had some suggestions on how to better to this, so I'll test that.

Tom
Previous Topic:sequence getting out of sync
Next Topic:EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace
Goto Forum:
  


Current Time: Tue Mar 19 04:35:14 GMT 2024

Powered by FUDForum. Page generated in 0.02019 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top