你好,我得到了以下实体类书: $
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@OneToOne(cascade=CascadeType.PERSIST)
private BookProfile bookProfile;
@OneToMany(cascade=CascadeType.PERSIST , orphanRemoval=true, fetch=FetchType.EAGER)
private List<Rating> ratings;
$
我尝试添加这样的个人资料:
$
Book book = manager.find(Book.class, bId);
BookProfile bookProfile = new BookProfile();
manager.getTransaction().begin();
book.setBookProfile(bookProfile);
manager.merge(book);
manager.getTransaction().commit();
$
但是Book中的配置文件仍然无效。我做错了什么?
答案 0 :(得分:3)
您需要将MERGE
添加到bookProfile
字段的级联类型中。