日期:2014-05-18  浏览次数:20874 次

hibernate中的save问题
javax.servlet.ServletException: org.springframework.dao.InvalidDataAccessApiUsageException: com.entity.User; nested exception is org.hibernate.TransientObjectException: com.entity.User
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.util.FilterClass.doFilter(FilterClass.java:24)


root cause 

org.springframework.dao.InvalidDataAccessApiUsageException: com.entity.User; nested exception is org.hibernate.TransientObjectException: com.entity.User
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:633)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
com.dao.daoimpl.BodycheckDaoImpl.adduserinfo(BodycheckDaoImpl.java:42)
com.delegate.delegateimpl.BodycheckdelegateImpl.adduserinfo(BodycheckdelegateImpl.java:24)
com.web.struts.action.BodyCheckAction.adduserinfo(BodyCheckAction.java:69)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.util.FilterClass.doFilter(FilterClass.java:24)


root cause 

org.hibernate.TransientObjectException: com.entity.User
org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:4