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

发布于 2024-09-30 03:19:23 字数 1058 浏览 6 评论 0原文

我有以下 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;

抛出以下异常:

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")

序列由 EclipseLink 生成,查询:

SELECT myschema.person_s1.NEXTVAL FROM DUAL

直接使用时工作正常...

任何帮助表示

赞赏 Marcel

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月野兔 2024-10-07 03:19:23

抛出以下异常(...)

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

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

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?

鱼窥荷 2024-10-07 03:19:23

我知道这听起来很愚蠢,但无论如何。

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

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文