简体   繁体   English

spring数据JPA无法创建主键,出现此错误SQL错误:2289,SQLState:42000 ORA-02289:序列不存在

[英]spring data jpa unable to create primary key getting this error SQL Error: 2289, SQLState: 42000 ORA-02289: sequence does not exist

I am working with springboot, spring data jpa ,Oracle db. 我正在使用springboot,spring data jpa,Oracle db。 If i changed the schema i am getting this error, without schema change everything is working fine. 如果我更改了架构,则会收到此错误,如果不更改架构,一切都会正常进行。

I am not using sequence 我没有使用序列

  @Entity
    @Table(name = "CLIENTS")
    public class CLIENTS implements Serializable {

        private static final long serialVersionUID = 123;

        @Id
        @Column(name = "ID")
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Integer clientId;

        @Column(name = "CODE")
        private Integer code;

        @Column(name = "REC_ID")
        private Integer recId;
//setters, getters, etc
    }

"I am not using sequence". “我没有使用序列”。 Sure you are. 当然可以。 GenerationType.AUTO has chosen it for you out of TABLE , SEQUENCE and IDENTITY . GenerationType.AUTO SEQUENCE TABLESEQUENCEIDENTITY为您选择了它。

The sequence exists in the old schema, but if you change the schema you need to create the sequence in the new schema too. 序列存在于旧模式中,但是如果更改模式,则也需要在新模式中创建序列。

Extend to Kayaman 扩展到Kayaman

Oracle @GeneratedValue(strategy = GenerationType.AUTO ) Spring data jpa (or) Hibernate will create a sequence itself and it is used for all insertions , that sequence name HIBERNATE_SEQUENCE , we have to create into new schema, if not exist Oracle @GeneratedValue(strategy = GenerationType.AUTO )Spring数据jpa(或)Hibernate会自己创建一个序列,并将其用于所有插入,该序列名称为HIBERNATE_SEQUENCE ,如果不存在,我们必须创建到新模式中

To know the all sequences 了解所有序列

SQL>select * from user_sequences;

For Creating sequence 用于创建序列

SQL> create sequence HIBERNATE_SEQUENCE



SQL>create sequence HIBERNATE_SEQUENCE
    start with 1 increment by 1 maxvalue 9999999999999999999999999999 minvalue 1 cache 20;

FOR delete Sequence FOR删除序列

SQL> drop   sequence HIBERNATE_SEQUENCE;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ORA-02289序列不存在,找不到我的错误 - ORA-02289: sequence does not exist, cannot find my error ORA-02289: 序列不存在 - 当使用 Spring 数据 JPA 和 Spring 启动时 - ORA-02289: sequence does not exist - when using Spring Data JPA with Spring boot ORA-02289: 序列不存在,休眠错误 - ORA-02289: sequence does not exist, error in hibernbate ORA-02289: 序列不存在 - 选择键或将结果设置到参数 object 时出错 - ORA-02289: sequence does not exist - Error selecting key or setting result to parameter object JPA(休眠):“ ORA-02289序列不存在”,但确实存在 - JPA (Hibernate): “ORA-02289 Sequence does not exist”, but it does 错误:ORA-02289:序列不存在 - org.hibernate.exception.SQLGrammarException:无法提取 ResultSet - ERROR: ORA-02289: sequence does not exist - org.hibernate.exception.SQLGrammarException: could not extract ResultSet ORA-02289:将Hibernate 3升级到休眠4时序列不存在 - ORA-02289: sequence does not exist when upgrade Hibernate 3 to hibernate 4 ORA-02289序列不存在,但是数据库中存在序列 - ORA-02289: sequence does not exist, however sequence is aleady exist in database java.sql.SQLSyntaxErrorException: ORA-02289: 在 Hibernate 和 Oracle 中使用默认生成策略时序列不存在 - java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist while using default Generation Strategy in Hibernate with Oracle 线程“主” org.hibernate.exception.SQLGrammarException中的异常:ORA-02289:序列不存在 - Exception in thread “main” org.hibernate.exception.SQLGrammarException: ORA-02289: sequence does not exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM