Marcel Menz
Marcel Menz

Reputation: 1105

sequence does not exist exception using eclipseLink with oracle db

I've got the following JPA entity:

@Entity
@Table(schema = "myschema")
@SequenceGenerator(schema = "myschema", name = "seqGenerator", 
                   sequenceName  = "person_s1", allocationSize = 1)
public class Person {

@Id
@GeneratedValue(generator = "seqGenerator", strategy = GenerationType.AUTO)
private long id;

the following exceptions are thrown:

Call: DROP SEQUENCE myschema.person_s1
Query: DataModifyQuery(sql="DROP SEQUENCE myschema.person_s1")
[EL Warning]: 2010-11-01 17:21:51.051--ServerSession(10605044)--Exception [EclipseLink-    4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): 
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-02289: sequence does not exist

Error Code: 2289
Call: SELECT myschema.person_s1.NEXTVAL FROM DUAL
Query: ValueReadQuery(sql="SELECT myschema.person_s1.NEXTVAL FROM DUAL")

The sequence is genrated by EclipseLink and the query:

SELECT myschema.person_s1.NEXTVAL FROM DUAL

works fine when used directly...

Any help appreciated

Regards Marcel

Upvotes: 3

Views: 8005

Answers (2)

Pascal Thivent
Pascal Thivent

Reputation: 570295

the following exceptions are thrown (...)

These traces are generated during schema creation when a particular database object doesn't exist and thus can't be dropped. EclipseLink report such cases as Warning (which are not Error), they can be ignored (you get your sequence, right?).

PS: Why do you use an allocation size of 1, don't you want to benefit from the high/low optimization?

Upvotes: 3

lscoughlin
lscoughlin

Reputation: 2406

I know this is going to sound really silly, but here it is anyway.

@Entity
@Table(schema = "myschema")
public class Person {

   @Id
   @SequenceGenerator(schema = "myschema", name = "seqGenerator", sequenceName  = "person_s1", allocationSize = 1)
   @GeneratedValue(generator = "seqGenerator", strategy = GenerationType.AUTO)
   private Long id;
}

Upvotes: 0

Related Questions