我在Oracle数据库12c中有一个表,它是用以下DDL创建的:
create table customer (
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR(100)
);我正在尝试使用Ebean.save方法将一行插入到此表中,模型定义如下:
@Entity
@Table(name = "customer")
public class Customer {
@Id
Integer id;
....用于插入行的代码如下:
Customer customer = new Customer();
customer.setName(name);
Ebean.save(customer);它失败,堆栈跟踪如下:
Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:446)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1054)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:623)
....
Caused by: Error : 2289, Position : 7, Sql = select
customer_seq.nextval, a from (select level as a FROM dual CONNECT BY level <= 20), OriginalSql = select customer_seq.nextval, a from (select level as a FROM dual CONNECT BY level <= 20), Error Msg = ORA-02289: sequence does not exist从错误中,我所理解的是Ebean试图对identity列使用Sequence策略,但是失败了。我尝试按如下方式设置Identity策略,但没有成功,可能是因为Ebean对Oracle DB使用了Sequence策略,正如here所解释的那样。
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Integer id;有没有办法保存Oracle 12c表中具有自动生成的标识列的行,就像上面使用Ebean定义的那样?通过设置IDENTITY策略,我是否走上了正确的道路?
https://stackoverflow.com/questions/48486638
复制相似问题