我有一个A类,其中包含B类对象的列表,当我保存A时,仅保存B的ID,没有其他属性
@Entity
表结构:
Class A{
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String id;
private String name;
private String address1;
private String address2;
@JoinColumn
@ManyToOne
private AGroup aGroup;
@JoinColumn
@ManyToOne
private Currency currency;
private Date createdOn;
private Date updatedOn;
@OneToMany(mappedBy = "a", cascade = CascadeType.PERSIST)
private Collection<B> b;
}
Class B{
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String id;
@ManyToOne
@JoinColumn
private A a;
private Date createdOn;
private Date updatedOn;
}
在保存A之前,我看到B的列表对于对象A是正确的,但是在保存之后,只为B保存了ID,尽管它也应该正确保存。