1

您好,我得到了以下实体类书籍:$

@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 中的配置文件仍然为空。我究竟做错了什么 ?

4

1 回答 1

3

您需要为您的字段添加MERGE级联类型。bookProfile

于 2012-11-24T14:21:06.837 回答