Org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifier:

Source: Internet
Author: User

JSP Page Save operation Error:

Org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifier:

--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------

exception

Org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifier: Com.hycrm.bean.Customer; Nested exception is org.hibernate.TransientObjectException:The given object have a null Identifier:com.hycrm.bean.Custom Erorg.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException ( sessionfactoryutils.java:654) Org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException (Hibernateaccessor.java : 412) Org.springframework.orm.hibernate3.HibernateTemplate.doExecute (hibernatetemplate.java:411) Org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession (hibernatetemplate.java:374) Org.springframework.orm.hibernate3.HibernateTemplate.update (hibernatetemplate.java:705) Org.springframework.orm.hibernate3.HibernateTemplate.update (hibernatetemplate.java:701) Com.hycrm.dao.impl.CustomerDAOImpl.updateCustomer (customerdaoimpl.java:39) Com.hycrm.service.impl.CustomerServiceImpl.update (customerserviceimpl.java:43) com. Hycrm.action.user.CustomerAction.updateCustomer (CUSTOMERACTION.JAVA:80) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Com.opensymphony.xwork2.DefaultActionInvocation.invokeAction (defaultactioninvocation.java:453) Com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly (defaultactioninvocation.java:292) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:255) Org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept (debugginginterceptor.java:256) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept (defaultworkflowinterceptor.java:176 ) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (METHODFIlterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (Defaultactioninvocation.java : 249) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept (validationinterceptor.java:265) Org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept ( annotationvalidationinterceptor.java:68) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept ( methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept ( conversionerrorinterceptor.java:138) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept ( parametersinterceptor.java:211) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept ( methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (DEFAULTACTIONINVOCation.java:249) Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept ( parametersinterceptor.java:211) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept ( methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept ( staticparametersinterceptor.java:190) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Org.apache.struts2.interceptor.MultiselectInterceptor.intercept ( multiselectinterceptor.java:75) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Org.apache.struts2.interceptor.CheckboxInterceptor.intercept ( CHECKBOXINTERCEPTOR.JAVA:90) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Org.apache.struts2.interceptor.FileUploadInterceptor.intercept ( fileuploadinterceptor.java:243) Com.opensymphony.xwork2.DefaultActionInvoCation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept (modeldriveninterceptor.java:100) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept (Scopedmodeldriveninterceptor.java : 141) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept (chaininginterceptor.java:145) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept (prepareinterceptor.java:171) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept (i18ninterceptor.java:176) Com.openSymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Org.apache.struts2.interceptor.ServletConfigInterceptor.intercept (servletconfiginterceptor.java:164) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept (aliasinterceptor.java:192) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept (exceptionmappinginterceptor.java:187 ) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Org.apache.struts2.impl.StrutsActionProxy.execute (strutsactionproxy.java:54) Org.apache.struts2.dispatcher.Dispatcher.serviceAction (dispatcher.java:510) Org.apache.struts2.dispatcher.FilterDispatcher.doFilter (filterdispatcher.java:434)

Root cause

Org.hibernate.TransientObjectException:The given object has a null identifier: Com.hycrm.bean.Customerorg.hibernate.event.def.DefaultSaveOrUpdateEventListener.getUpdateId ( defaultsaveorupdateeventlistener.java:272) Org.hibernate.event.def.DefaultUpdateEventListener.getUpdateId ( defaultupdateeventlistener.java:69) org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached ( defaultsaveorupdateeventlistener.java:240) Org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate (defaultupdateeventlistener.java:56) Org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate (Defaultsaveorupdateeventlistener.java : Org.hibernate.impl.SessionImpl.fireUpdate (sessionimpl.java:592) org.hibernate.impl.SessionImpl.update ( sessionimpl.java:580) org.hibernate.impl.SessionImpl.update (sessionimpl.java:572) Org.springframework.orm.hibernate3.hibernatetemplate$14.doinhibernate (hibernatetemplate.java:708) Org.springframework.orm.hibernate3.HibernateTemplate.doExecute (Hibernatetemplate.java:406) Org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession ( hibernatetemplate.java:374) Org.springframework.orm.hibernate3.HibernateTemplate.update (Hibernatetemplate.java : 705) org.springframework.orm.hibernate3.HibernateTemplate.update (hibernatetemplate.java:701) Com.hycrm.dao.impl.CustomerDAOImpl.updateCustomer (customerdaoimpl.java:39) Com.hycrm.service.impl.CustomerServiceImpl.update (customerserviceimpl.java:43) Com.hycrm.action.user.CustomerAction.updateCustomer (CUSTOMERACTION.JAVA:80) SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native Method) Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) Sun.reflect.DelegatingMethodAccessorImpl.invoke ( DELEGATINGMETHODACCESSORIMPL.JAVA:25) Java.lang.reflect.Method.invoke (method.java:597) Com.opensymphony.xwork2.DefaultActionInvocation.invokeAction (defaultactioninvocation.java:453) Com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly (defaultactioninvocation.java:292) com.opensymphony.xWork2. Defaultactioninvocation.invoke (defaultactioninvocation.java:255) Org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept (debugginginterceptor.java:256) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept (defaultworkflowinterceptor.java:176 ) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept (validationinterceptor.java:265) Org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept ( annotationvalidationinterceptor.java:68) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept ( methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.Interceptor. Conversionerrorinterceptor.intercept (conversionerrorinterceptor.java:138) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept (parametersinterceptor.java:211) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept (parametersinterceptor.java:211) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept (staticparametersinterceptor.java:190 ) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Org.apache.struts2.interceptor.MultiselectInteRceptor.intercept (multiselectinterceptor.java:75) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Org.apache.struts2.interceptor.CheckboxInterceptor.intercept ( CHECKBOXINTERCEPTOR.JAVA:90) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Org.apache.struts2.interceptor.FileUploadInterceptor.intercept ( fileuploadinterceptor.java:243) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept ( modeldriveninterceptor.java:100) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept ( scopedmodeldriveninterceptor.java:141) Com.opensymphony.xwork2.DefaultActionInvocation.invoke ( defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept ( chaininginterceptor.java:145) Com.opensymphony.xwOrk2. Defaultactioninvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept (prepareinterceptor.java:171) Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:98) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept (i18ninterceptor.java:176) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Org.apache.struts2.interceptor.ServletConfigInterceptor.intercept (servletconfiginterceptor.java:164) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept (aliasinterceptor.java:192) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept (Exceptionmappinginterceptor.java: 187) Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:249) Org.apache.struts2.impl.StrutsActionProxy.execute (strutsactionproxy.java:54) Org.apache.struts2.dispatcher.Dispatcher.serviceAction (dispatcher.java:510) Org.apache.struts2.dispatcher.FilterDispatcher.doFilter (filterdispatcher.java:434)

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------

Due to missing primary key

Workaround:

Join the primary key in the JSP page <s:hidden name= "***.id" ></s:hidden>

Org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifier:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.