问题描述
java.lang.IllegalStateException:org.hibernate.TransientPropertyValueException:objectreferencesanunsavedtransientinstance-savethetransientinstancebeforeflushing:com.jianfeitech.ordercenter.entity.order.OrderInfo.bindingType->com.jianfeitech.ordercenter.entity.common.CommonDataatorg.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1374)atorg.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)atorg.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:266)atcom.jianfeitech.ordercenter.service.impl.order.OrderInfoManagerImpl.findByCcustomerId(OrderInfoManagerImpl.java:1444)atcom.jianfeitech.ordercenter.service.impl.order.OrderInfoManagerImpl$$FastClassBySpringCGLIB$$4436f794.invoke(<generated>)atorg.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)atorg.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:711)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)atorg.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)atorg.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)atorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)atorg.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)atcom.jianfeitech.ordercenter.service.impl.order.OrderInfoManagerImpl$$EnhancerBySpringCGLIB$$e49c8d55.findByCcustomerId(<generated>)atcom.jianfeitech.ordercenter.web.order.OrderController.findAllCcustomer(OrderController.java:3132)atcom.jianfeitech.ordercenter.web.order.OrderController$$FastClassBySpringCGLIB$$d8a496fe.invoke(<generated>)atorg.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)atorg.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:640)atcom.jianfeitech.ordercenter.web.order.OrderController$$EnhancerBySpringCGLIB$$38762f6f.findAllCcustomer(<generated>)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)atorg.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:707)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:820)atorg.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)atorg.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1324)atcom.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)atcom.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)atorg.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1295)atorg.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)atorg.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)atorg.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)atorg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)atorg.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)atorg.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)atorg.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)atorg.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)atorg.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)atorg.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)atorg.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)atorg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)atorg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)atorg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)atorg.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1295)atorg.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:177)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)atorg.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1295)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)atorg.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1295)atorg.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:440)atorg.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)atorg.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)atorg.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)atorg.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1033)atorg.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:369)atorg.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)atorg.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:967)atorg.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)atorg.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)atorg.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)atorg.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)atorg.eclipse.jetty.server.Server.handle(Server.java:358)atorg.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)atorg.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)atorg.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)atorg.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)atorg.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)atorg.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)atorg.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)atorg.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)atorg.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)atorg.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)atjava.lang.Thread.run(Thread.java:745)
解决方案
解决方案二:
某一个数据类型转换的问题吧
解决方案三:
findByCcustomerId方法及相关entity类代码贴出来看看估计是保存OrderInfo对象的时候级联保存了其它没有id的entity.
解决方案四:
com.jianfeitech.ordercenter.entity.common.CommonData有问题
解决方案五:
packagecom.jianfeitech.ordercenter.entity.crm;importjavax.persistence.CascadeType;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.FetchType;importjavax.persistence.GeneratedValue;importjavax.persistence.GenerationType;importjavax.persistence.Id;importjavax.persistence.ManyToOne;importjavax.persistence.SequenceGenerator;importjavax.persistence.Table;@Entity@Table(name="c_address")@SequenceGenerator(name="caddressSEQ",sequenceName="CADDRESS_SEQUENCE",allocationSize=1)publicclassCaddress{@Id@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="caddressSEQ")privateLongid;//省份@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionprovince;//城市@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregioncity;//区县@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionarea;//详细地址@Column(length=200)privateStringfullAddress;//客户信息privateLongccustomerId;publicLonggetId(){returnid;}publicvoidsetId(Longid){this.id=id;}publicCregiongetProvince(){returnprovince;}publicvoidsetProvince(Cregionprovince){this.province=province;}publicCregiongetCity(){returncity;}publicvoidsetCity(Cregioncity){this.city=city;}publicCregiongetArea(){returnarea;}publicvoidsetArea(Cregionarea){this.area=area;}publicStringgetFullAddress(){returnfullAddress;}publicvoidsetFullAddress(StringfullAddress){this.fullAddress=fullAddress;}publicLonggetCcustomerId(){returnccustomerId;}publicvoidsetCcustomerId(LongccustomerId){this.ccustomerId=ccustomerId;}}
解决方案六:
packagecom.jianfeitech.ordercenter.entity.crm;importjavax.persistence.CascadeType;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.FetchType;importjavax.persistence.GeneratedValue;importjavax.persistence.GenerationType;importjavax.persistence.Id;importjavax.persistence.ManyToOne;importjavax.persistence.SequenceGenerator;importjavax.persistence.Table;@Entity@Table(name="c_address")@SequenceGenerator(name="caddressSEQ",sequenceName="CADDRESS_SEQUENCE",allocationSize=1)publicclassCaddress{@Id@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="caddressSEQ")privateLongid;//省份@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionprovince;//城市@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregioncity;//区县@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionarea;//详细地址@Column(length=200)privateStringfullAddress;//客户信息privateLongccustomerId;publicLonggetId(){returnid;}publicvoidsetId(Longid){this.id=id;}publicCregiongetProvince(){returnprovince;}publicvoidsetProvince(Cregionprovince){this.province=province;}publicCregiongetCity(){returncity;}publicvoidsetCity(Cregioncity){this.city=city;}publicCregiongetArea(){returnarea;}publicvoidsetArea(Cregionarea){this.area=area;}publicStringgetFullAddress(){returnfullAddress;}publicvoidsetFullAddress(StringfullAddress){this.fullAddress=fullAddress;}publicLonggetCcustomerId(){returnccustomerId;}publicvoidsetCcustomerId(LongccustomerId){this.ccustomerId=ccustomerId;}}
解决方案七:
packagecom.jianfeitech.ordercenter.entity.crm;importjavax.persistence.CascadeType;importjavax.persistence.Column;importjavax.persistence.Entity;importjavax.persistence.FetchType;importjavax.persistence.GeneratedValue;importjavax.persistence.GenerationType;importjavax.persistence.Id;importjavax.persistence.ManyToOne;importjavax.persistence.SequenceGenerator;importjavax.persistence.Table;@Entity@Table(name="c_address")@SequenceGenerator(name="caddressSEQ",sequenceName="CADDRESS_SEQUENCE",allocationSize=1)publicclassCaddress{@Id@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="caddressSEQ")privateLongid;//省份@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionprovince;//城市@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregioncity;//区县@ManyToOne(optional=true,cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)privateCregionarea;//详细地址@Column(length=200)privateStringfullAddress;//客户信息privateLongccustomerId;publicLonggetId(){returnid;}publicvoidsetId(Longid){this.id=id;}publicCregiongetProvince(){returnprovince;}publicvoidsetProvince(Cregionprovince){this.province=province;}publicCregiongetCity(){returncity;}publicvoidsetCity(Cregioncity){this.city=city;}publicCregiongetArea(){returnarea;}publicvoidsetArea(Cregionarea){this.area=area;}publicStringgetFullAddress(){returnfullAddress;}publicvoidsetFullAddress(StringfullAddress){this.fullAddress=fullAddress;}publicLonggetCcustomerId(){returnccustomerId;}publicvoidsetCcustomerId(LongccustomerId){this.ccustomerId=ccustomerId;}}
解决方案八:
com.jianfeitech.ordercenter.entity.order.OrderInfo.bindingType->com.jianfeitech.ordercenter.entity.common.CommonData你这两个对象是不是哪里关联出问题了。你是不是CommonData时间类型转换出问题了??
解决方案九:
保存之前flush