Hibernate常见异常总结
系统配置
1.没有查找到src目录下的hibernate.cfg.xml
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xmlnot found
映射配置
2.在系统配置文件cfg.xml文件中写的映射文件名不存在
Exception in thread "main" org.hibernate.MappingNotFoundException: resource: cn/itcast/h3/user/UserModel.hbm.xml not found
3.配置文件中的映射属性名与模型中的属性名不统一
Caused by: org.hibernate.PropertyNotFoundException: field [name] not found on cn.itcast.h3.user.UserModel
4.配置文件中的数据库列名名与数据库表中的字段名名不统一
Caused by: java.sql.BatchUpdateException: Unknown column 'user' in 'field list'
操作增删改
5.在进行保存前,如果对象OID没有设置值,并且生成策略为assigned
Exception in thread "main" org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.itcast.h3.user.UserModel
6.当操作保存一个数据时,如果OID对应的值存在
Exception in thread "main" org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
Caused by: java.sql.BatchUpdateException: Duplicate entry '5' for key 1
7.执行增删改语句发生错误,具体操作具体分析
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
8.进行删改语句未找到影响的数据,抛出该异常,OID不存在
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
9.Hibernate在试图操作一个对象时,检测出该对象是TO对象,不具有OID,而执行非save相关的操作
Exception in thread "main" org.hibernate.TransientObjectException: The given object has a null identifier: cn.itcast.h3.cache.UserModel
10.一级缓存中加载两个不同的对象具有相同的OID数据
Exception in thread "main" org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [cn.itcast.h3.cache.UserModel#15]
操作查询
11.使用load方法读取数据时,如果对应的OID不存在数据
Exception in thread "main" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [cn.itcast.h3.api.UserModel#100]
12.QBC查询时,直接使用关联对象名.属性名作为查询条件
Exception in thread "main" org.hibernate.QueryException: could not resolve property: teacher.teacherName of: cn.itcast.h3.relation.vo.StudentModel
13.对HQL进行参数设置时,索引位置错误
Exception in thread "main" org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 2
14.查询结果不唯一,使用uniqueResult方法得到超过一条数据
Exception in thread "main" org.hibernate.NonUniqueResultException: query did not return a unique result: 5
其他
15.在Hibernate操作对象过程中试图修改对象的OID
Exception in thread "main" org.hibernate.HibernateException: identifier of an instance ofcn.itcast.h3.cache.UserModel was altered from 3 to null
16.操作数据时,一个数据关联了瞬时对象,抛出异常
Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: cn.itcast.h3.one2many.StudentModel
17.当Session关闭后,试图加载对象中延迟加载数据
Exception in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: cn.itcast.h3.relation.vo.TeacherModel. students, no session or session was closed
Hibernate常见异常总结的更多相关文章
- 【转】Hibernate 常见异常
转载地址:http://smartan.iteye.com/blog/1542137 Hibernate 常见异常net.sf.hibernate.MappingException 当出 ...
- Hibernate 常见异常
Hibernate 常见异常net.sf.hibernate.MappingException 当出现net.sf.hibernate.MappingException: Error r ...
- HIbernate常见异常(转载)
SSH阶段常见的异常系列之一hibernate(15条) 异常一 异常一 异常描述: Sax解析异常:cvc-复杂的类型,发现了以元素maping开头的无效内容,应该是以 ‘{“http://www. ...
- spring+hibernate常见异常集合
spring+hibernate出错小结: (1)java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext ...
- Hibernate常见异常
1.数据库编码问题 主要错误信息 WARN: SQL Error: 1366, SQLState: 22001 ... ERROR: Data truncation: Incorrect string ...
- Hibernate常见错误整理
Hibernate常见错误合集 1.错误:object references an unsaved transient instance - save the transient instance ...
- struts2.1.8+hibernate2.5.6+spring3.0(ssh2三大框架)常见异常原因和解决方案
---------------------------------------------------------------------------------------------------- ...
- orcal 数据库 maven架构 ssh框架 的全xml环境模版 及常见异常解决
创建maven项目后,毫不犹豫,超简单傻瓜式搞定dependencies(pom.xml 就是maven的依赖管理),这样你就有了所有你要的包 <project xmlns="http ...
- Maven常见异常及解决方法(本篇停更至16-4-12)
本篇文章记录了老猫在学习整合Maven和SSH过程中遇到的问题,有的问题可以解决.有的问题还不能解决. 方法不一定适合全部的环境.但绝对是本人常遇到的常见异常.在这里做一个笔记和记录,也分享给大家,希 ...
随机推荐
- BZOJ3745:[COCI2015]Norma
浅谈离线分治算法:https://www.cnblogs.com/AKMer/p/10415556.html 题目传送门:https://lydsy.com/JudgeOnline/problem.p ...
- FPGA中竞争冒险问题的研究
什么是竞争冒险? 1 引言 现场可编程门阵列(FPGA)在结构上由逻辑功能块排列为阵列,并由可编程的内部连线连接这些功能块,来实现一定的逻辑功能. FPGA可以替代其他PLD或者各种中小规模数 ...
- SVN 命令使用-***
1.检出到某一版本: svn checkout -r 974 svn://220.231.xx.xx/仓库名 svn checkout svn://220.231.xx.xx/仓库名 svn ex ...
- Docker持续化集成和测试
基于容器的自动构建:Docker在美团的应用 https://linux.cn/article-5465-1.html Docker持续化集成和测试,关于docker-in-docker问题 h ...
- 智能提示框---bai
input.jsp <%@ page language="java" import="java.util.*" pageEncoding="UT ...
- 开发环境入门 linux基础 基本操作命令(部分) 文本结构和基本命令
文本结构和基本命令 linux系统中系统提示符:$ 表示普通用户 su root切换用户命令(用户名 root),输入密码,切换到其他用户状态 root 命令提示符:# exit 退出当前用户,返回 ...
- java 多线程系列基础篇(十)之线程优先级和守护线程
1. 线程优先级的介绍 java 中的线程优先级的范围是1-10,默认的优先级是5.“高优先级线程”会优先于“低优先级线程”执行. java 中有两种线程:用户线程和守护线程.可以通过isDaemon ...
- 类型:.net;问题:asp.net window验证;结果:细说ASP.NET Windows身份认证
细说ASP.NET Windows身份认证 阅读目录 开始 认识ASP.NET Windows身份认证 访问 Active Directory 在ASP.NET中访问Active Directory ...
- springmvc 在页面跳转之后 引入文件的路径前面加上了 controller 的映射名
转自:https://zhidao.baidu.com/question/2140453086362943788.html 应该是没有前面的/user的 前端用的是jsp吗,如果是在路径前加${pag ...
- eclipse自动生成带参数说明方法注释
自动生成方法的注释格式,例如 /*** @param str* @return * @throws ParseException*/ 快捷键是alt+shift+j,将光标放在方法名上,按快捷键.会 ...