1.异常:org.hibernate.AnnotationException: No identifier specified for entity异常。

entity类是必须要主键的,否则就会报出这个异常。
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Integer id;

2.异常:exception just for purpose of providing stack trace

count(*) 返回的结果为Long类型,而非Integer

3.异常 org.hibernate.UnknownEntityTypeException

在使用spring的orm时,entity类没在hibernate sessionFactory的扫描中,导致。@entity要使用javax的entity而不是hibernate的。

  1. <bean id="sessionFactory"
  2. class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
  3. <property name="dataSource" ref="dataSource" />
  4. <property name="packagesToScan">
  5. <list>
  6. <!-- 可以加多个包 -->
  7. <value>com.test.common.entity</value>
  8. </list>
  9. </property>
  10. <property name="hibernateProperties">
  11. <props>
  12. <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
  13. <prop key="hibernate.dialect">${hibernate.dialect}</prop>
  14. <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
  15. <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
  16. <prop key="hibernate.format_sql">true</prop>
  17. </props>
  18. </property>
  19. </bean>

4. org.hibernate.HibernateException: identifier of an instance of com.*.*DO was altered from 27 to null

出现这样的异常是从get中获取do对象,在进行更新前,将主键id给置为null导致。注意 BeanUtils.copyProperties,会将导入对象的null也给导入过来。

5. org.hibernate.HibernateException:Multiple references to database, sequence  [**] were encountered attempting toset conflict values for initial value

出现的原因是在entity中有两个重复的实体类对应了sequence,多见于实体类重命名后mvn没有重新clean导致。  mvn clean package

hibernate 异常的更多相关文章

  1. Hibernate 异常总结

    异常一 异常一 异常描述: Sax解析异常:cvc-复杂的类型,发现了以元素maping开头的无效内容,应该是以 ‘{“http://www.hibernate.org/xsd/orm/cfg“:pr ...

  2. Hibernate 异常 —— No CurrentSessionContext configured

    在使用 SessionFactory 的 getCurrentSession 方法时遇到如下异常 “No CurrentSessionContext configured ” 原因是: 在hibern ...

  3. Hibernate 异常 —— Unable to instantiate default tuplize

    出现这个异常 —— Unable to instantiate default tuplizer ,是 Hibernate 的映射文件(*.hbm.xml)导致的.仔细检查一下工程里的映射文件吧. 笔 ...

  4. Hibernate 异常 集锦

    异常1.Error parsing JNDI name [foo] 异常信息摘要: org.hibernate.engine.jndi.JndiException: Error parsing JND ...

  5. hibernate异常:org.hibernate.exception.GenericJDBCException

    异常:org.hibernate.exception.GenericJDBCException 提示:Cannot open connection 提示:不能打开链接 一般这个异常是由 java.sq ...

  6. hibernate异常:org.hibernate.MappingException

    这个是映射文件配置错误 异常:org.hibernate.MappingException 提示:Could not determine type for: java.lang,String, at ...

  7. hibernate异常:org.hibernate.NonUniqueObjectException

    异常:org.hibernate.NonUniqueObjectException 提示:a different object with the same identifier value was a ...

  8. Hibernate异常之命名查询节点未找到

    异常信息: java.lang.IllegalArgumentException: No query defined for that name [salaryEmps] at org.hiberna ...

  9. Hibernate异常之Integer转float(自动类型转换错误)

    错误代码: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Float at org.hiber ...

  10. Java EE 之Hibernate异常总结【1】org.hibernate.LazyInitializationException: could not initialize proxy - no Session

    字面意义就是不能被初始化. 简单理解就是因为,你使用了lazy=true,这样hibernate在从数据库中调数据的时候是不会把关联的对象查出来的,而是保存一个获取值得方法,在你使用getXXX()调 ...

随机推荐

  1. web 纯 javascript 的MVC 实现的简单实践

    现在javascript是越来越火了,好多javascript框架随之产生,大大简化了我们的开发,一般的开发模式大家是比较喜欢MVC 的model controller view 这种模式 方便了我们 ...

  2. Linux挂载命令

    版权声明:本文为"bcoder编程网"原创文章.原文地址:http://www.bcoder.cn,欢迎訪问! https://blog.csdn.net/wang7396/art ...

  3. Python与机器学习

    pandas里面的对于数据操作比如where,drop以及dropna等都会有一个属性:inplace,这个单词意思是原地,如果inplace=true代表数据本身要返回(原地数据也会被改变):如果i ...

  4. Go 的类型断言type assertion

    Go语言中的类型断言,语法上是这样的: x.(T) 其中,x是interface接口的表达式,T是类型,称为被断言类型. 补充一下,接口有接口值的概念,其包括动态类型和动态值两部分. 类型断言根据T的 ...

  5. linux下的pd

    东西叫OpenSystemArchitect 地址在http://www.codebydesign.com/SystemArchitect 运行之前,先sudo apt-get install lib ...

  6. Java之优先队列

    PriorityQueue属于Java Collections Framework.PriorityQueue基于优先级堆,它是Queue接口的实现.当我们需要一个Queue实现时,可以使用这种数据结 ...

  7. bzoj4271: chemistry 化学

    给定点数n<=500,无标号,度<=4,无根树计数 预处理 无标号,孩子数<=3的有根树个数g 无标号,含k棵树,孩子数<=3的有根树森林个数s[k] 考虑大小为n的无根树的重 ...

  8. centos-linux热拔插scsi硬盘

    自己配置虚拟机,需要添加一块虚拟硬盘存放数据.虚拟机在更新软件,不想停机.学习了下热拔插硬盘的知识点 1. 在虚拟机中创建虚拟磁盘并添加. 2. 查看目前的磁盘信息cat /proc/scsi/scs ...

  9. [UE4]让AI跑起来

    让AI由静止状态变成跑步状态,做法跟玩家角色走路一样. 一.创建1D混合动画 二.在AI角色关联的动画蓝图中使用第一步创建的混合动画

  10. 一个关于考勤统计的sql研究

    在这里,我们要做一个简单的员工考勤记录查询系统的后台数据库.业务需求如下所示:      1.统计每天来的最早.来的最晚.走的最早.走得最晚的人的姓名           1.1 统计每天来得最早的人 ...