detached entity passed to persist: com.test.usermanage.model.User

简介: 点击打开转载地址Exception in thread "main" javax.persistence.PersistenceException: org.

点击打开转载地址

Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.test.usermanage.model.User

at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:881)
at com.test.usermanage.test.ClientEntity.main(ClientEntity.java:27)
Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: com.test.usermanage.model.User
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:141)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:852)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:826)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:830)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:875)

... 1 more

User user = new User();
user.setId(2);
改:
User user = new User();
user.setId(null);


相关文章
|
19天前
Cannot load keys from store: class path resource
Cannot load keys from store: class path resource
11 0
|
3月前
|
TensorFlow 算法框架/工具 Python
完美解决丨RuntimeError: create_session() called before __init__().
完美解决丨RuntimeError: create_session() called before __init__().
|
8月前
|
Ubuntu 数据安全/隐私保护
All data created during this guest session will be deleted when you log out 问题的解决
All data created during this guest session will be deleted when you log out 问题的解决
Changing scope values asynchronously - updates don't propagate without .apply()
Changing scope values asynchronously - updates don't propagate without .apply()
Changing scope values asynchronously - updates don't propagate without .apply()
|
Java
Hybris DDIC type and its counterpart model class
Hybris DDIC type and its counterpart model class
110 0
Hybris DDIC type and its counterpart model class
component set load logic - why coms_pcat_bob is accessed during product search
component set load logic - why coms_pcat_bob is accessed during product search
111 0
component set load logic - why coms_pcat_bob is accessed during product search
When should reread of cl_crm_bol_entity and $scope.$apply be called manually
When should reread of cl_crm_bol_entity and $scope.$apply be called manually
119 0
When should reread of cl_crm_bol_entity and $scope.$apply be called manually
User Parameter UI2WD_TRKORR_CUST is not maintained
User Parameter UI2WD_TRKORR_CUST is not maintained
93 0
User Parameter UI2WD_TRKORR_CUST is not maintained