Hibernate持久性异常

时间:2015-09-10 20:39:26

标签: java hibernate spring-mvc

@Entity
Class A{

//assume proper annotations present
private Long id;
@OneToMany(@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)   
private List<B> b;

//all getters and setters are present...

}

代码:

A a =//get a from data base using hibernate by id
//a contains b also
a.setId(null);
entityDao.persist(a);//line at which i am getting exception

例外:

Caused by: javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: B

当使用merge而不是persist时,一切正常。但我想知道持续存在的问题是什么?

0 个答案:

没有答案
相关问题