系统配置

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常见异常总结的更多相关文章

  1. 【转】Hibernate 常见异常

    转载地址:http://smartan.iteye.com/blog/1542137 Hibernate 常见异常net.sf.hibernate.MappingException        当出 ...

  2. Hibernate 常见异常

    Hibernate 常见异常net.sf.hibernate.MappingException        当出现net.sf.hibernate.MappingException: Error r ...

  3. HIbernate常见异常(转载)

    SSH阶段常见的异常系列之一hibernate(15条) 异常一 异常一 异常描述: Sax解析异常:cvc-复杂的类型,发现了以元素maping开头的无效内容,应该是以 ‘{“http://www. ...

  4. spring+hibernate常见异常集合

    spring+hibernate出错小结: (1)java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext ...

  5. Hibernate常见异常

    1.数据库编码问题 主要错误信息 WARN: SQL Error: 1366, SQLState: 22001 ... ERROR: Data truncation: Incorrect string ...

  6. Hibernate常见错误整理

    Hibernate常见错误合集   1.错误:object references an unsaved transient instance - save the transient instance ...

  7. struts2.1.8+hibernate2.5.6+spring3.0(ssh2三大框架)常见异常原因和解决方案

    ---------------------------------------------------------------------------------------------------- ...

  8. orcal 数据库 maven架构 ssh框架 的全xml环境模版 及常见异常解决

    创建maven项目后,毫不犹豫,超简单傻瓜式搞定dependencies(pom.xml 就是maven的依赖管理),这样你就有了所有你要的包 <project xmlns="http ...

  9. Maven常见异常及解决方法(本篇停更至16-4-12)

    本篇文章记录了老猫在学习整合Maven和SSH过程中遇到的问题,有的问题可以解决.有的问题还不能解决. 方法不一定适合全部的环境.但绝对是本人常遇到的常见异常.在这里做一个笔记和记录,也分享给大家,希 ...

随机推荐

  1. SQLite连接C#笔记

    不得不吐槽,实在是太坑了.以下几点一定要注意: 要下载两个东西,都要上官网.一个是SQLite for Windows,一个是System.Data.SQLite. 下载下来的DLL里面有个test, ...

  2. QString 乱谈(1)

    一个月前尝试写了一篇关于QStringLiteral,存盘时MoinMoin罢工了.吸取一点经验,还是写成短篇吧 可是,可是,QString不就是简简单单一个字符串么?能有什么可谈的.真的么... ( ...

  3. kafka集群安装和kafka-manager

    1.软件环境 (3台服务器-测试)10.11.12.31 mykafka110.11.12.32 mykafka210.11.12.33 mykafka3 [root@localhost ~]# ca ...

  4. appium-unittest框架中的断言

    1.首先unittest本身是一个python的测试框架,他有他自己的使用规则: 2.如果用其中的方法,需要引入,方法: import unittest class Login(unittest.Te ...

  5. DAY17-Django之model增删改

    添加表记录 普通字段 #方式1 publish_obj=Publish(name="人民出版社",city="北京",email="renMin@16 ...

  6. VS2010 rdlc报表无法显示“数据源”选项

  7. 保研机试训练[bailianoj]

    site:http://bailian.openjudge.cn/xly2018/ 1.计算任意两天之间的天数 思路:以0为起始点计算天数,然后相减即可.这样的编码复杂度会减少很多. #include ...

  8. Group Layout

    ----------------siwuxie095                             将根面板 contentPane 的布局切换为 Group Layout     Grou ...

  9. Go语言-变量和常量

    我们在这里需要优先说明的是用于声明变量的关键字var,以及用于声明常量的关键字const.要知道,绝大多数的数据类型的值都可以被赋给一个变量,包括函数.而常量则不同,它只能被赋予基本数据类型的值本身. ...

  10. SQL server2008无法收缩日志

    SQL server2008无法收缩日志,错误信息为: 1:由于最小日志空间要求,无法收缩日志文件 2:无法收缩日志文件 2 (XXX_log),因为该文件结尾的逻辑日志文件正在使用 描述: 用的是网 ...