jpa - Hibernate Problem ( javax.persistence.PersistenceException: org.hibernate.PersistentObjectException) -
here problem description.
i have 2 objects "a" , "b"."a" has onetoone(cascadetype= cascadetype.all) relationship object "c".even "b" has onetoone(cascadetype = cascadetype.all) relationship "c".
now need persist object "a".and after persist object "a" ,i need persist object "b".i can persist object "a" ,but when persist "b" exception
javax.persistence.persistenceexception: org.hibernate.persistentobjectexception
the reason object "c" persisted when "a" persisted.and when "b" being persisted tries persist "c" again.thats why persistenceexception.
i tried merge object c before persist object "b".even same exception.
please provide me work around.
also let me know if 1 needs further info.
here full stack trace
caused by: javax.persistence.persistenceexception: org.hibernate.persistentobjectexception: detached entity passed persist: com.project.shared.entity.user @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1235) @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1168) @ org.hibernate.ejb.abstractentitymanagerimpl.convert(abstractentitymanagerimpl.java:1174) @ org.hibernate.ejb.abstractentitymanagerimpl.persist(abstractentitymanagerimpl.java:674) @ com.sun.enterprise.container.common.impl.entitymanagerwrapper.persist(entitymanagerwrapper.java:258) @ com.project.server.bean.expertfacade.create(expertfacade.java:64) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.glassfish.ejb.security.application.ejbsecuritymanager.runmethod(ejbsecuritymanager.java:1052) @ org.glassfish.ejb.security.application.ejbsecuritymanager.invoke(ejbsecuritymanager.java:1124) @ com.sun.ejb.containers.basecontainer.invokebeanmethod(basecontainer.java:5243) @ com.sun.ejb.ejbinvocation.invokebeanmethod(ejbinvocation.java:615) @ com.sun.ejb.containers.interceptors.aroundinvokechainimpl.invokenext(interceptormanager.java:797) @ com.sun.ejb.ejbinvocation.proceed(ejbinvocation.java:567) @ com.sun.ejb.containers.interceptors.systeminterceptorproxy.doaround(systeminterceptorproxy.java:157) @ com.sun.ejb.containers.interceptors.systeminterceptorproxy.aroundinvoke(systeminterceptorproxy.java:139) @ sun.reflect.generatedmethodaccessor64.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ com.sun.ejb.containers.interceptors.aroundinvokeinterceptor.intercept(interceptormanager.java:858) @ com.sun.ejb.containers.interceptors.aroundinvokechainimpl.invokenext(interceptormanager.java:797) @ com.sun.ejb.containers.interceptors.interceptormanager.intercept(interceptormanager.java:367) @ com.sun.ejb.containers.basecontainer.__intercept(basecontainer.java:5215) @ com.sun.ejb.containers.basecontainer.intercept(basecontainer.java:5203) @ com.sun.ejb.containers.ejblocalobjectinvocationhandler.invoke(ejblocalobjectinvocationhandler.java:190) ... 69 more
thanks
a detached entity entity has identifier, not present in current session. when try save it, hibernate complains. have put in session. done via entitymanager.merge(..)
.
Comments
Post a Comment