Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » SequenceGenerator Error(does not go beyond the AllocationSize)
SequenceGenerator Error [message #831881] Thu, 29 March 2012 09:31 Go to next message
pattabi  is currently offline pattabi
Messages: 5
Registered: August 2011
Junior Member
Hi,
I am trying to insert a large number of records from within a for loop. The insert fails with Integrity violation exception once the record number reaches the Allocation size of the SequenceGenerator. I was able to reproduce by changing the allocationSize.

Please find the relevant pieces of information. Could somebody help?

	@SequenceGenerator(name="CACHE_KEY_GENERATOR", sequenceName="CACHE_KEY_SEQ", initialValue=1, allocationSize=100)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CACHE_KEY_GENERATOR" )


and the sequence SQL is
CREATE SEQUENCE CACHE_KEY_SEQ START WITH 100 MAXVALUE 999999999999999999999999999 MINVALUE 100 NOCYCLE CACHE 20 ;

The exception trace is

Error Code: 1
Call: INSERT INTO CACHE (KEY, ADDRESS_1, ADDRESS_2, ADDRESS_3, CITY, COUNTRY, FIRST_NAME, LAST_NAME, POSTAL_CODE, STATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
	bind => [2, 5500 HWY U  , null, null, TROY, US, null, null, 63379, MO]
Query: InsertObjectQuery(com.pcg.ds.vendorservice.domain.Cache@13a26de)
.....
Query: InsertObjectQuery(com.pcg.ds.vendorservice.domain.Cache@13a26de)
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:840)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:906)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:592)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)

Re: SequenceGenerator Error [message #832074 is a reply to message #831881] Thu, 29 March 2012 14:34 Go to previous messageGo to next message
pattabi  is currently offline pattabi
Messages: 5
Registered: August 2011
Junior Member
I switched to Hibernate. Based on the user experience, seems to be a problem with Eclipse link. With Hibernate, I did not get any error. Also, the sequence needed to be started at 100 for another possible bug in Eclipselink.
Re: SequenceGenerator Error [message #832821 is a reply to message #832074] Fri, 30 March 2012 12:22 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1017
Registered: July 2009
Senior Member
My guess is your problem has to do with the allocationSize being set to 100, while your sequence object is only incrementing by 1. Due to your setup, the first time it is accessed the sequence will return a value of 100. Because the allocation size is set to 100, that means to EclipseLink that it should be able to use 1-100 before needing to get a sequence value again. When it does, it will get 101, and so try to use 2-101 which will cause a problem.

Your allocation size must match the allocation used by the sequence object. If this works elsewhere, either that provider is ignoring the allocation size, or you have configured it differently.

Best Regards,
Chris
Re: SequenceGenerator Error [message #866124 is a reply to message #832821] Mon, 30 April 2012 14:55 Go to previous message
pattabi  is currently offline pattabi
Messages: 5
Registered: August 2011
Junior Member
Thanks for the information and it worked when I changed the allocationSize to 1.
Sorry for the delay, as I could not switch the provider earlier.
Thanks
Previous Topic:Where is the javax.persistence in EclipseLink?
Next Topic:quoted name and constraint
Goto Forum:
  


Current Time: Thu Aug 28 23:24:57 EDT 2014

Powered by FUDForum. Page generated in 0.10407 seconds