带有Eclipselink的Oracle 12c标识列

时间:2016-02-29 11:38:41

标签: java oracle eclipselink oracle12c

我在Oracle 12c数据库中有一个定义为MSG_ID NUMBER(24, 0) GENERATED BY DEFAULT ON NULL AS IDENTITY NOT NULL的列。我尝试使用Eclipselink 2.6.2

在其表中插入多条记录

这是我的实体类:

    @Entity
    @Table(name = "MY_TABLE", catalog = "", schema = "MYSCHEMA")
    @XmlRootElement
    @PrimaryKey(validation = IdValidation.NULL)
    public class MyTable implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Basic(optional = false)
        @Column(name = "MSG_ID")
        private Long msgId;
        @Basic(optional = false)
        @Column(name = "MSG")
        private String msg;
        @Basic(optional = false)
        @Column(name = "SENDER")
        private String sender;

        // Getters and setters...
    }

当我创建一个循环以在表中插入多个记录时,我得到以下异常:

--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

Error Code: 942
Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
    bind => [2 parameters bound]
Query: DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?")

之后,跟随java.lang.IllegalArgumentException: An instance of a null PK has been incorrectly provided for this find operation。因为表格没有生成ID,也没有处理ID生成的序列。

这是Eclipselink中的错误还是我在代码中犯的错误?

0 个答案:

没有答案