系统配置

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. ConcurrentHashMap的扩容机制(jdk1.8)

    ConcurrentHashMap相关的文章网上有很多,而关于ConcurrentHashMap扩容机制是很关键的点,尤其是在并发的情况下实现数组的扩容的问题经常会碰到,看到这篇写的具有代表性,详细讲 ...

  2. MySQL最新版本 MySQL5.7.11 批量自动化一键式安装(转)

    --背景云端 以前都喜欢了源码安装MySQL,总觉得源码是高大上的事情,不过源码也需要时间,特别是make的时候,如果磁盘和cpu差的话,时间很长很长,在虚拟机上安装mysql尤其甚慢了. 现在业务发 ...

  3. Oracle data guard学习

    Oracle data guard学习:三思笔记 Data guard 1data guard结构: data guard是一个集合,由一个primary数据库(生产数据库)和一个或多个standby ...

  4. Ubuntu登录异常: 输入正确的密码, 但是却无法进入系统, 总是返回到登录界面, 但是用ctrl+alt+F1-F文字界面登录都可以进入。

    今天打开电脑的时候, 在输入密码之后, 未进入ubuntu的桌面, 而是显示了几行英文之后有返回到了登录界面.显示的英文如下: could not write bytes: Broken pipe   ...

  5. 跨数据文件删除flashback database

    Oracle flashback database的使用有一些限制,其中最主要的是flashback database不支持跨数据文件删除闪回和不支持跨数据文件shrink闪回.对于已经删除的数据文件 ...

  6. ansible for devops读书笔记第一章

    yum -y install ansible ansible --version mkdir /etc/ansible touch /etc/ansible/hosts [example]   www ...

  7. C语言学习笔记--指针概念

    指针也是一种变量,占有内存空间,用来保存内存地址,在32位系统中指针的占用的内存大小为4个字节 1.*号的意义 (1)在指针声明时,*号表示所声明的变量为指针 (2)在指针使用时,*号表示取指针所指向 ...

  8. C语言学习笔记--#error 、 #line 和 #pragma 的使用

    1. #error 的用法 (1)#error 是一种预编译器指示字,用于生成一个编译错误消息 (2)用法:#error message //注意:message 不需要用双引号包围 (3)#erro ...

  9. JVM知识点总览

    jvm 总体梳理 jvm体系总体分四大块: 类的加载机制 jvm内存结构 GC算法 垃圾回收 GC分析 命令调优 当然这些知识点在之前的文章中都有详细的介绍,这里只做主干的梳理 这里画了一个思维导图, ...

  10. Codeforces #536 div2 E (1106E)Lunar New Year and Red Envelopes (DP)

    题意:过年了,Bob要抢红包.抢红包的时间段为1 - n,有m个红包,每个红包有三个属性:st(红包出现的时间), ed(红包消失的时间),d(如果抢了这个红包,能够抢下一个红包的时间),w(红包的收 ...