org.hibernate.transientobjectexception:The given object has a null identifier: com.gxuwz.check.entit
错误信息:
org.hibernate.TransientObjectException: The given object has a null identifier: com.gxuwz.check.entity.SysAttendanceorg.hibernate.event.internal.DefaultSaveOrUpdateEventListener.getUpdateId(DefaultSaveOrUpdateEventListener.java:265)org.hibernate.event.internal.DefaultUpdateEventListener.getUpdateId(DefaultUpdateEventListener.java:70)org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:233)org.hibernate.event.internal.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:55)org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)org.hibernate.internal.SessionImpl.fireUpdate(SessionImpl.java:779)org.hibernate.internal.SessionImpl.update(SessionImpl.java:771)org.hibernate.internal.SessionImpl.update(SessionImpl.java:767)com.gxuwz.check.dao.CheckDaoImpl.update(CheckDaoImpl.java:169)com.gxuwz.check.dao.CheckDaoImpl.saveByUserId(CheckDaoImpl.java:157)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)com.sun.proxy.$Proxy9.saveByUserId(Unknown Source)com.gxuwz.check.action.CheckAction.saveCheckRecord(CheckAction.java:134)sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)java.lang.reflect.Method.invoke(Method.java:498)com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)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:248)com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)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:248)com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
错误描述:给的对象没有id值,hibernate更新失败。
错误的原因:
在hibernate映射文件中给了一个id值,并且是自增的,但是在修改时没有给id赋值导致。
确实在保存时候传入主键,尽管在创建的时候已经指定了主键自动生成,但是在修改/更新时如果不传主键,那么hibernate无法识别到底是哪一个记录需要被修改,所以就会报错。
解决方案:
在修改过程中,给id赋值,可以通过在表单中添加一个隐藏域,来保存id的值。
比如:
<input type="hidden" name ="id" value="${stulist.id}">
org.hibernate.transientobjectexception:The given object has a null identifier: com.gxuwz.check.entit相关推荐
- 关于出现org.hibernate.TransientObjectException: The given object has a null identifier: 错误的解决方法
关于出现org.hibernate.TransientObjectException: The given object has a null identifier: 错误的解决方法 参考文章: (1 ...
- org.hibernate.TransientObjectException:The given object has a null identifier
1.错误描述 org.hibernate.TransientObjectException:The given object has a null identifier:com.you.model.U ...
- [Ljava.lang.Object; cannot be cast to com.gxuwz.check.entity.SysClasses
今天在写ssh项目的时候遇到了这样一个问题,我在数据库通过连表查询A老师下的所有班级的时候,把查出来的所有内容(所有字段)放到List里面,代码如下: /** * @title: queryClass ...
- 解决The given object has a null identifier问题
首先阐述下问题.第一次做的是插入操作,第二次在来是进行更改.用的是hibernate框架操作.如果遇到和我相同的问题,可能可以借鉴一下,我是这么解决的! 首先在实体类重写tostring方法. act ...
- org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifi的解决方案
异常信息: org.springframework.dao.InvalidDataAccessApiUsageException: The given object has a null identi ...
- a different object with the same identifier val...
2019独角兽企业重金招聘Python工程师标准>>> a different object with the same identifier value was already a ...
- 解决a different object with the same identifier value was already associated with the session错误...
问题场景: (我要做对象修改,然后保存进数据库) 我通过数据库获取一个原对象obj; 然后新增了一个修改对象obj1; 然后将obj1.setId(obj.getId()); 然后调用数据库实例对象S ...
- Exception in thread main org.hibernate.TransientObjectException: object references an unsaved tran
今天在使用一对多,多对一保存数据的时候出现了这个错误 Hibernate错误: Exception in thread "main" org.hibernate.Transient ...
- 关于hibernate 更新或者删除报错different object with the same identifier
Hibernate 疑难异常及处理 1.a different object with the same identifier value was already associated with th ...
最新文章
- 使用熔断器设计模式保护软件
- postgresql数据库导入导出
- xampp 中mysql中文乱码
- 《Android 面试指南》
- php base64_decode 图片,php读取和保存base64编码图片
- 2018首届世界传感器大会11月12日-14日在郑州召开
- Required method destroyItem was not overridden
- nn.functional.normalize
- BZOJ 1778: [Usaco2010 Hol]Dotp 驱逐猪猡
- 简单算法一个(有N个人,依照顺序报123,数到3的人自动出局,问最后剩下的那个人在原来的队列中排第几)
- 【微信网页授权】SpringBoot+uniapp实现网页授权获取用户基本信息
- ORACLE TRUNCATE 的用法
- win10下解决编译环境find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer
- 什么是推荐系统与常见的推荐系统评价指标
- 论国产PLC产业化发展
- 武汉理工大学计算机专业强化,2020年武汉理工大学计算机改考408
- 公网中的Winbox
- 写作三步构思法TCS:【tone,content,structure】基调、内容、结构
- win7计算机搜索功能没有了,正版win7旗舰版电脑的搜索功能不见了怎么办
- 曹健老师 TensorFlow2.1 —— 第三章 神经网络八股
热门文章
- Android赚钱的方法--界面嵌入有米广告(持续关注中)
- OpenCV在Python上的调用( import cv2的解决办法)
- C++11判断inf, nan
- VC++实现任务管理器功能
- linux系统下常用或有用的系统级命令
- mysql行列转换_Excel、SQL、Python分别实现行列转换
- 【阿里云北京峰会】一图看懂阿里云GPU实例如何帮助企业在AI应用赛道上加速...
- 编码最佳实践——Liskov替换原则
- Memcached主从复制+keepalived高可用架构
- SVN提示:由于目标机器积极拒绝,无法连接 的解决方法