引用exception
javax.servlet.
ServletException: org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.grxxh.heen.Heen.cname; nested exception is org.
hibernate.PropertyValueException: not-null property references a null or transient value: com.grxxh.heen.Heen.cname
org.apache.
struts.action.RequestProcessor.processException(RequestProcessor.java:514)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.grxxh.heen.Heen.cname; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.grxxh.heen.Heen.cname
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:690)
com.grxxh.heen.dao.impl.HeenDAO.save(HeenDAO.java:38)
com.grxxh.heen.service.impl.Heen
Service.addHeen(HeenService.java:24)
com.grxxh.struts.action.AddHeenAction.execute(AddHeenAction.java:58)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.grxxh.heen.Heen.cname
org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
org.hibernate.event.def.
DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:693)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:690)
com.grxxh.heen.dao.impl.HeenDAO.save(HeenDAO.java:38)
com.grxxh.heen.service.impl.HeenService.addHeen(HeenService.java:24)
com.grxxh.struts.action.AddHeenAction.execute(AddHeenAction.java:58)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:430)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
几种解决办法:
1.其中有一个字段不允许为空,需要给它赋值就可以了
2.DataIntegrityViolationException
not-null
你把数据库中的属性全都改为允许为空!解决问题!
非空属性引用了一个空的或者瞬时(游离状态)的值,可能是引用的值还没有进行持久化吧,还处于游离状态
以上是别人的办法 , 我的还没解决呢! 解决了之后再来补充!
补充:
我的问题错在JSP页面form里面input的name跟我后台框架的name属性不对应,所以取值没取回来。简单说,我把name的大小写没区分。尴尬啊尴尬!