Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带hibernate can的Spring数据jpa';按顺序找不到列_Java_Spring_Hibernate_Sequence - Fatal编程技术网

Java 带hibernate can的Spring数据jpa';按顺序找不到列

Java 带hibernate can的Spring数据jpa';按顺序找不到列,java,spring,hibernate,sequence,Java,Spring,Hibernate,Sequence,所以我在我的SpringMVC项目中使用PostgreSQL数据库,我创建了一个表,其中包含主键生成的序列。我在hibernate获取插入行的下一个值时遇到了一个问题。这就是我的实体的外观: @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "employee_s") @SequenceGenerator(name = "employee_s", sequenceName = "employee_s", in

所以我在我的SpringMVC项目中使用PostgreSQL数据库,我创建了一个表,其中包含主键生成的序列。我在hibernate获取插入行的下一个值时遇到了一个问题。这就是我的实体的外观:

@Id 
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "employee_s")
@SequenceGenerator(name = "employee_s", sequenceName = "employee_s", initialValue = 1, allocationSize = 1)
@Column(name = "id_pk")
private Long id;
我在插入数据时出错,如下所示:

org.postgresql.util.PSQLException: ERROR: Column "next_val" does not exist
这个专栏并不是按顺序存在的,但为什么连hibernate都在寻找这个专栏呢

但当我改变世代策略时,它起了作用:

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_pk")
private Long id;
我如何使用序列策略来修复它,或者我应该坚持使用标识,因为它是有效的?PostgreSQL使用策略,所以我想尝试一下