ERROR DemandDAO:72 - save failed org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save(): com.pax.hlportal.persistence.hibernate.data.demand.Demand; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pax.hlportal.persistence.hibernate.data.demand.DemandCaused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pax.hlportal.persistence.hibernate.data.demand.Demandat org.hibernate.id.Assigned.generate(Assigned.java:33)at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:686)at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:369)at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:683)at com.pax.hlportal.persistence.hibernate.data.demand.DemandDAO.save(DemandDAO.java:68)at com.pax.hlportal.presentation.web.controller.saleinfo.DemController.onSubmit(DemController.java:151)at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:774)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:460)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:425)at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834)at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)at java.lang.Thread.run(Unknown Source)
------解决方法--------------------------------------------------------
主键需要手动设置
------解决方法--------------------------------------------------------
ids for this class must be manually assigned before calling save()
,hibernate出现这个错误的原因有可能因为,你的表中有个主键。 但是在执行save()的时候却没有给Id设置值,如调用xxx.setId(..)等方法,才会出现。
------解决方法--------------------------------------------------------
这跟主键的生成策略有关。