首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Ejb3持久化实体时的错误

2012-10-21 
Ejb3持久化实体时的异常对某个Entity进行持久化操作时发生如下异常Caused by: org.hibernate.PersistentOb

Ejb3持久化实体时的异常

对某个Entity进行持久化操作时发生如下异常Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: xxx原因:应该使用merge的地方使用了persist

?

补充em.merge()与em.persist()的区别,如下(以下内容来自网络)

?

Either way will add an entity to a PersistenceContext, the difference is in what you do with the entity afterwards.

Persist takes an entity instance, adds it to the context and makes that instance managed (ie future updates to the entity will be tracked)

Merge creates a new instance of your entity, copies the state from the supplied entity, and makes the new copy managed. The instance you pass in will not be managed (any changes you make will not be part of the transaction - unless you call merge again).

?

// tran ends and the row for someField is updated (the changes were made to e2, not e)

?

热点排行