[英]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
TABLE
, SEQUENCE
和IDENTITY
为您选择了它。
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.