Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #725231] Wed, 14 September 2011 10:06 Go to next message
Sam Ratcliff is currently offline Sam RatcliffFriend
Messages: 3
Registered: September 2011
Junior Member

I am using MS SQL Server 2008 which is automatically detected by EclipseLink on start up. What I am trying to do is to use a history customiser to maintain the log of a table which has an auto-increment identity column as the primary key. The definition of the table and its corresponding history table:

CREATE TABLE [dbo].[organisation_external_identifier](
[externalIdentifierKey] [bigint] IDENTITY(1,1) NOT NULL,
[organisationKey] [bigint] NOT NULL,
[schemeKey] [bigint] NOT NULL,
[identifier] [nvarchar](255) NOT NULL,
CONSTRAINT [PK_organisation_external_identifier] PRIMARY KEY CLUSTERED
[externalIdentifierKey] ASC

CREATE TABLE [hist].[organisation_external_identifier](
[externalIdentifierKey] [bigint] NOT NULL,
[organisationKey] [bigint] NOT NULL,
[schemeKey] [bigint] NOT NULL,
[identifier] [nvarchar](255) NOT NULL,
[startDate] [datetime] NOT NULL,
[endDate] [datetime] NULL,
CONSTRAINT [PK_organisation_external_identifier] PRIMARY KEY CLUSTERED
[externalIdentifierKey] ASC,
[startDate] ASC

When I am trying to insert an organisation into the table I receive the below stack trace.

Exception Description: Error preallocating sequence numbers. The sequence table information is not complete.
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal( [eclipselink.jar:2.3.0.v20110604-r9504]
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit( [eclipselink.jar:2.3.0.v20110604-r9504]
at com.daiwacm.rts.organisation.master.OrganisationMasterImpl.loadTestData( [bin/:na]

Using the debugger to find the trace of execution of where the exception is actually thrown:

NativeSequence(StandardSequence).getGeneratedValue(Accessor, AbstractSession, String) line: 63
NativeSequence(Sequence).getGeneratedValue(Accessor, AbstractSession) line: 225
SequencingManager$NoPreallocation_State.getNextValue(Sequence, AbstractSession) line: 677
SequencingManager.getNextValue(AbstractSession, Class) line: 1067
ClientSessionSequencing.getNextValue(Class) line: 70
ObjectBuilder.assignSequenceNumber(Object, AbstractSession, WriteObjectQuery) line: 360
ObjectBuilder.assignSequenceNumber(WriteObjectQuery) line: 333
StatementQueryMechanism(DatabaseQueryMechanism).updateObjectAndRowWithSequenceNumber() line: 841
StatementQueryMechanism(DatasourceCallQueryMechanism).insertObject() line: 337
StatementQueryMechanism.insertObject() line: 162
HistoryPolicy.logicalInsert(ObjectLevelModifyQuery, boolean) line: 773
HistoryPolicy.postInsert(ObjectLevelModifyQuery) line: 732
ExpressionQueryMechanism(DatabaseQueryMechanism).insertObjectForWrite() line: 489
InsertObjectQuery.executeCommit() line: 80

At the bold line the value of the "object" parameter has the field which holds the identity value correctly set to a valid identifier from the database, yet it still decides that it needs to ask the database again for the identifier which I assume is what is failing.

The eclipselink logging which immediately precedes the thrown exception is:
[EL Finest]: 2011-09-14 10:53:35.633--ClientSession(815749913)--Thread(Thread[qtp1485988078-14,5,main])--Execute query ValueReadQuery(name="SEQ_GEN_IDENTITY" sql="SELECT @@IDENTITY")
[EL Fine]: 2011-09-14 10:53:35.634--ClientSession(815749913)--Connection(341973975)--Thread(Thread[qtp1485988078-14,5,main])--SELECT @@IDENTITY
[EL Finest]: 2011-09-14 10:53:35.634--UnitOfWork(773185343)--Thread(Thread[qtp1485988078-14,5,main])--assign sequence to the object (43 -> DAIWATEST)
[EL Finest]: 2011-09-14 10:53:35.635--UnitOfWork(773185343)--Thread(Thread[qtp1485988078-14,5,main])--Execute query InsertObjectQuery(DAIWATEST~bcp)
[EL Fine]: 2011-09-14 10:53:35.635--ClientSession(815749913)--Connection(341973975)--Thread(Thread[qtp1485988078-14,5,main])--INSERT INTO dbo.organisation_external_identifier (identifier, organisationKey, schemeKey) VALUES (?, ?, ?)
bind => [bcp, 51, 43]
[EL Finest]: 2011-09-14 10:53:35.636--ClientSession(815749913)--Thread(Thread[qtp1485988078-14,5,main])--Execute query ValueReadQuery(name="SEQ_GEN_IDENTITY" sql="SELECT @@IDENTITY")
[EL Fine]: 2011-09-14 10:53:35.636--ClientSession(815749913)--Connection(341973975)--Thread(Thread[qtp1485988078-14,5,main])--SELECT @@IDENTITY
[EL Finest]: 2011-09-14 10:53:35.636--UnitOfWork(773185343)--Thread(Thread[qtp1485988078-14,5,main])--assign sequence to the object (32 -> DAIWATEST~bcp)
[EL Fine]: 2011-09-14 10:53:35.637--ClientSession(815749913)--Connection(341973975)--Thread(Thread[qtp1485988078-14,5,main])--INSERT INTO hist.organisation_external_identifier (externalIdentifierKey, identifier, organisationKey, schemeKey, startDate) VALUES (?, ?, ?, ?, ?)
bind => [32, bcp, 51, 43, 2011-09-14 10:53:35.637]
[EL Finest]: 2011-09-14 10:53:35.638--ClientSession(815749913)--Thread(Thread[qtp1485988078-14,5,main])--Execute query ValueReadQuery(name="SEQ_GEN_IDENTITY" sql="SELECT @@IDENTITY")
[EL Fine]: 2011-09-14 10:53:35.638--ClientSession(815749913)--Connection(341973975)--Thread(Thread[qtp1485988078-14,5,main])--SELECT @@IDENTITY

I think this is possibly a bug as when I remove the history customiser it works fine and does not encounter any issues. it is only with the history customiser activated that the problem occurs.

Sorry there is lots of trace etc but hopefully everything anyone should need is listed.

Re: (no subject) [message #895147 is a reply to message #725231] Wed, 11 July 2012 19:51 Go to previous messageGo to next message
Nick Padilla is currently offline Nick PadillaFriend
Messages: 16
Registered: August 2011
Location: New Mexico
Junior Member
Hey Sam,

I am currently trying to work in History into my application. I have been having issues with Primary key conflicts when EclipseLink is trying to insert the changed/updated entity. The update to the 'live' table happens with no problems however keeps throwing the com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException and I have tried several different options to solve this problem, but to no avail. Did you ever find a work around for this?
Re: (no subject) [message #899633 is a reply to message #895147] Wed, 01 August 2012 15:56 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I think this is bug#347539

The issue is with IDENTITY id generation and history. Try using TABLE sequencing.

Previous Topic:SQLServer, IDENTITY and History issue
Next Topic:When an Entity has two different relationships to another Entity which is identified by Compound PKs
Goto Forum:

Current Time: Thu Mar 30 08:56:17 GMT 2017

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

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