Problem with sequence setup

View: New views
2 Messages — Rating Filter:   Alert me  

Problem with sequence setup

by Bijkerk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I'm using Eclipselink version 1.1.2 and I have the following problem:

If I have a simply entity with the following item representing the primary key
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_S1")
@SequenceGenerator(name = "SEQUENCE_S1", sequenceName = "SEQUENCE_S1", allocationSize = 100)
@Column(name = "ID", nullable = false)
private Long id;

And the SEQUENCE_S1 is a freshly created uninitialized sequence with increment by value of 100.

Then my unit test case, that is persisting an entity, will fail with the following exception:
org.springframework.dao.DataIntegrityViolationException:
Exception Description: The sequence named [SEQUENCE_S1] is setup incorrectly.  Its increment does not match its pre-allocation size.; nested exception is javax.persistence.EntityExistsException:

The really weird thing is. If I have the allocationsize set to 1 or if I by hand initialize the sequence before I run the unit test, the unit test will NOT fail. Or even when I change nothing and just run the test a second time, it will not fail.

I'm inclined to think that there may be some issues when persisting an entity to the (Oracle XE 10g) database with an uninitialized sequence and allocationSize is not 1.

Can someone help me in finding the cause and solution of this problem?

Thanks in advance,
Ruud Bijkerk,
Oracle


Re: Problem with sequence setup "increment does notmatch its pre-allocation size.; nested exception isjavax.persistence.EntityExistsException: Exception Description: Thesequence named [REL_PERSTITL_S1] is setup incorrectly. Its increme

by Andrei Ilitchev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Use 100 as a start value will resolve the problem:
by default the start value is 1, when Eclipselink attempts to use the first
allocated sequence value it's negative 1 - 100 + 1, that causes the
exception.
----- Original Message -----
From: "Bijkerk" <ruud.bijkerk@...>
To: <eclipselink-users@...>
Sent: Thursday, September 17, 2009 8:50 AM
Subject: [eclipselink-users] Problem with sequence setup "increment does
notmatch its pre-allocation size.; nested exception
isjavax.persistence.EntityExistsException: Exception Description:
Thesequence named [REL_PERSTITL_S1] is setup incorrectly. Its incrementdoes
not match its pre-allocation size.


>
> Hi All,
>
> I'm using Eclipselink version 1.1.2 and I have the following problem:
>
> If I have a simply entity with the following item representing the primary
> key
> @Id
> @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
> "SEQUENCE_S1")
> @SequenceGenerator(name = "SEQUENCE_S1", sequenceName = "SEQUENCE_S1",
> allocationSize = 100)
> @Column(name = "ID", nullable = false)
> private Long id;
>
> And the SEQUENCE_S1 is a freshly created uninitialized sequence with
> increment by value of 100.
>
> Then my unit test case, that is persisting an entity, will fail with the
> following exception:
> org.springframework.dao.DataIntegrityViolationException:
> Exception Description: The sequence named [SEQUENCE_S1] is setup
> incorrectly.  Its increment does not match its pre-allocation size.;
> nested
> exception is javax.persistence.EntityExistsException:
>
> The really weird thing is. If I have the allocationsize set to 1 or if I
> by
> hand initialize the sequence before I run the unit test, the unit test
> will
> NOT fail. Or even when I change nothing and just run the test a second
> time,
> it will not fail.
>
> I'm inclined to think that there may be some issues when persisting an
> entity to the (Oracle XE 10g) database with an uninitialized sequence and
> allocationSize is not 1.
>
> Can someone help me in finding the cause and solution of this problem?
>
> Thanks in advance,
> Ruud Bijkerk,
> Oracle
>
>
> --
> View this message in context:
> http://www.nabble.com/Problem-with-sequence-setup-%22increment-does-not-match-its-pre-allocation-size.--nested-exception-is-javax.persistence.EntityExistsException%3A--Exception-Description%3A-The-sequence-named--REL_PERSTITL_S1--is-setup-incorrectly.--Its-increment-does-not-match-its-pre-allocation-size.-tp25490599p25490599.html
> Sent from the EclipseLink - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@...
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>

_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users