我在Oracle Database 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正在尝试将Sequence
策略用于标识列,但它失败了。我尝试按照以下方式设置Identity
策略但没有取得任何成功,可能是因为Ebean正在使用Sequence
策略来解释Oracle here。
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Integer id;
有没有办法使用Ebean在上面定义的自动生成标识列的Oracle 12c表中保存行?通过设置IDENTITY
策略,我是否走在正确的轨道上?