object references an unsaved transient instance - save the transient instance before flushing异常

org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: cn.ccb.clpm.common.model.bo.documentservice.DocIndexBO
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:627)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:584)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:496)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:401)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:258)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy413.attach(Unknown Source)
at cn.ccb.clpm.bizprocess.loanservice.creditassetsriskclassi.generalclassiadjust.web.GeneralClassiAdjustBackingBean.submitGeneralAdjust(GeneralClassiAdjustBackingBean.java:831)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 

出现这种问题的时候,主要是因为Hibernate中的一对多,多对多等关联关系出现了问题造成的。 

比如: 对象1.对象2中,有可能对象1或者对象2等出现了问题。 有可能对象1中存在空的对象。

而且,这些对象1,对象2的操作要在同一个事务中进行处理,才不会报出此种错误!

 

 

你可能感兴趣的:(Hibernate,object)