小编Ada*_*dam的帖子

How to set an @Id primary key that is NOT Auto-Generated in Java JPA/Hibernate?

I am using Postgres with Java JPA/Hibernate and want to have the id field as one that is MANUALLY GENERATED by me. i.e. whenever i create an instance of this object, i set the id field anyway.

I've tried for weeks but keep running into either: "Required identifier property not found for class" or "After saving, the identifier must not be null".

Here is a sample of the model class i am using:

import javax.persistence.*;

@Entity
@Table(name = "pojo")
public …
Run Code Online (Sandbox Code Playgroud)

java postgresql hibernate jpa spring-boot

5
推荐指数
1
解决办法
7411
查看次数

标签 统计

hibernate ×1

java ×1

jpa ×1

postgresql ×1

spring-boot ×1