使用 eclipseLink 和 oracle db 时序列不存在异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4070951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:48:22  来源:igfitidea点击:

sequence does not exist exception using eclipseLink with oracle db

oraclejpasequenceeclipselink

提问by Marcel Menz

I've got the following JPA entity:

我有以下 JPA 实体:

@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:

该序列由 EclipseLink 和查询生成:

SELECT myschema.person_s1.NEXTVAL FROM DUAL

works fine when used directly...

直接使用时效果很好...

Any help appreciated

任何帮助表示赞赏

Regards Marcel

问候马塞尔

采纳答案by Pascal Thivent

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?).

当特定的数据库对象不存在因此无法删除时,这些跟踪是在模式创建期间生成的。EclipseLink 报告这样的情况Warning(不是Error),它们可以被忽略(你得到了你的序列,对吗?)。

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

PS:为什么你用1的分配大小,你不想从高/低优化中受益吗?

回答by lscoughlin

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;
}