hel*_*one 9 java hibernate jpa
我有一个名为 Task 的实体,它有 taskId 字段。问题是我需要创建/更新一些特定任务,而 JPA 自动生成器不允许我手动设置任务 ID。(它会覆盖我的任务 ID)
有没有办法手动设置taskId?
@Id
@Column(name = "task_id")
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
private String taskId;
Run Code Online (Sandbox Code Playgroud)
使用
@GeneratedValue(strategy = GenerationType.IDENTITY)
Run Code Online (Sandbox Code Playgroud)
示例: http: //www.codejava.net/frameworks/hibernate/java-hibernate-jpa-annotations-tutorial-for-beginners
| 归档时间: |
|
| 查看次数: |
17738 次 |
| 最近记录: |