我们说我有以下实体:
@Entity
public class A {
@Id
@Type(type = "pg-uuid")
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private UUID id;
@OneToMany
private List<B> bs;
// other fields + getter and setter
}
和
@Entity
public class B {
@Type(type = "pg-uuid")
private UUID aId;
// other fields + getter and setter
}
在创建包含A
列表的实体B
(使用JPA保存)期间,有没有办法使用A's uuid generator
填充aId
字段B
?或者我是否需要在java中使用UUID.randomUUID()
生成uuid,然后创建A/B
个实体?