在 Hibernate 和 Oracle 12c 中插入失败并出现 SQL 语法异常

Insertion fail with SQL Grammar Exception in Hibernate and Oracle 12c

我正在使用 JPA/Hibernate 4.3.7 和 Oracle 12c

当我尝试保留其中一个实体时,出现以下错误。

基本实体(配置文件)具有以下注释

@Inheritance(strategy = InheritanceType.JOINED)


 Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
    Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
    Caused by: java.sql.SQLSyntaxErrorException: ORA-02000: missing ) keyword

但是我在使用 hsqldb 时没有遇到这个问题。

SQL 在此处通过 Pastebin 进行跟踪 http://pastebin.com/rXrqzTQ0

@Entity
@DiscriminatorValue("CNT")
@Table(name = "containers")
public class Container extends Profile implements Serializable, IEntity {

    @ManyToOne(optional = false)
    @JoinColumn(name = "HIERARCHY_TYPES_ID", nullable = true, updatable = false)
    private HierarchyType hierarchyType;

    @ManyToOne(optional = false)
    @JoinColumn(name = "HIERARCHY_SUB_TYPES_ID", nullable = true, updatable = false)
    private HierarchySubType hierarchySubType;

    @ManyToOne(optional = false)
    @JoinColumn(name = "SEGMENT_ID", nullable = true, updatable = false)
    private Segment segment;

    @ManyToOne(optional = false)
    @JoinColumn(name = "SUB_SEGMENT_ID", nullable = true, updatable = false)
    private Subsegment subsegment;

    @ManyToOne(optional = false)
    @JoinColumn(name = "USERS_ID_HIERARCHY_OWNER", nullable = true, updatable = false)
    private User user;

    @Column(name = "CONTAINER_NAME", nullable = true, length = 200)
    private String containerName;

    public Container(String containerName) {
        this.containerName = containerName;
    }

    public Container() {
    }

    public HierarchyType getHierarchyType() {
        return hierarchyType;
    }

    public void setHierarchyType(HierarchyType hierarchyType) {
        this.hierarchyType = hierarchyType;
    }

    public HierarchySubType getHierarchySubType() {
        return hierarchySubType;
    }

    public void setHierarchySubType(HierarchySubType hierarchySubType) {
        this.hierarchySubType = hierarchySubType;
    }

    public Segment getSegment() {
        return segment;
    }

    public void setSegment(Segment segment) {
        this.segment = segment;
    }

    public Subsegment getSubsegment() {
        return subsegment;
    }

    public void setSubsegment(Subsegment subsegment) {
        this.subsegment = subsegment;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getContainerName() {
        return containerName;
    }

    public void setContainerName(String containerName) {
        this.containerName = containerName;
    }
}

似乎 "CONTAINERS" 是自 Oracle 12c 以来的保留字。

我必须将我的 table 重命名为 "CONTAINER" 然后我才能坚持。