Hibernate.hbm.xml
1、should be mapped with insert="false" update="false":存在重复映射的字段;
2、Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]:
配置文件与实体文件映射错误,多了字段或少了字段或少些了getter 方法;
3、org.hibernate.LazyInitializationException: could not initialize proxy - no Session:映射关系中加上 lazy="false";
4、org.hibernate.ObjectNotFoundException: No row with the given identifier exists:根据外键id查询不到映射表的相应数据;
5、Could not determine type for: String, for columns: [org.hibernate.mapping.Column(XXX)]:type指的是*.hbm.xml配置文件中的类型,string要小写;
6、nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists:映射表中数据的主键id不匹配;
7、org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of XXX:配置文件与实体类字段类型不一致;
8、org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1:级联新增,打印出来的sql语句显示主表为insert,从表为update 可以将配置文件中自增id设置 unsaved-value="0";
9、ConstraintViolationException: Could not execute JDBC batch update:两个表建立了外键约束,删除约束后操作成功;
10、 nested exception is org.springframework.beans.NotWritablePropertyException:
11、org.springframework.beans.factory.BeanCreationException:Spring中的“asm-2.2.3.jar”和Hibernate中的“asm.jar”包冲突。解决办法是移除Spring2.0 AOP Libraries中的“asm-2.2.3.jar”即可
12、org.springframework.beans.MethodInvocationException: 在classes目录有一个以前的类,但现在的类的路径已经发生了变化,发生变化的类全部封装在 jar 里面,但class loader 是优先装载 classes 目录下的类,所以存在装载时发生“NoClassDefFoundError”错误!只要把classes下的class文件删除即可。
13、com.sun.faces.mgbean.ManagedBeanCreationException:数据问题
14、a different object with the same identifier value was already associated with the session:getHibernateTemplate().merge(object);http://chenying.blog.51cto.com/614874/134702
15、not-found="ignore" 忽略ObjectNotFound异常;
转载地址:http://blog.csdn.net/hardwin/article/details/4329652
我们项目里面配了很多many-to-one的关联,后台在查询数据时已经作了健全性判断,但还是经常抛出对象找不到异常:org.hibernate.ObjectNotFoundException: No row with the given identifier exists
因为系统给用户使用过程中库表的数据会常发生变化,最常见的是人员变化,原先引用的User 在库表没了,hibernate 多对一关联,多的这端引用的一的那端,如此引用值在一的那端找不到数据,默认就会抛出异常;而后台判断控制不了此问题。解决办法就是在many-to- one的这端加上属性:not-found=ignore
hibernate many-to-one的属性not-found,用来指定引用的外键不存在时如何处理:
它有两个取值,exception(默认)抛出异常,ignore 忽略。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)