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的。

    <bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<!-- 可以加多个包 -->
<value>com.test.common.entity</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</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. Arrays、ArrayUtils 区别

    Arrays java.util 包提供的静态类:java.util.Arrays 此静态类专门用来操作array ,提供搜索.排序.复制等静态方法. ArrayUtils apache 提供的类:o ...

  2. 箭头函数中的 this

    JS 每一个 function 都有自己独立的运行上下文,但箭头函数不属于普通的 function,所以没有独立的上下文. 所以在箭头函数里写的 this 其实是包含该箭头函数最近的一个 functi ...

  3. POJ1734无向图求最小环

    题目:http://poj.org/problem?id=1734 方法有点像floyd.若与k直接相连的 i 和 j 在不经过k的情况下已经连通,则有环. 注意区分直接连接和间接连接. * 路径记录 ...

  4. AsyncTask使用详细说明

    AsyncTask使用: 在开发Android应用时必须遵守单线程模型的原则: Android UI操作并不是线程安全的并且这些操作必须在UI线程中执行.在单线程模型中始终要记住两条法则: 1. 不要 ...

  5. sublime text 3 3143

    下载链接:https://download.sublimetext.com/Sublime%20Text%20Build%203143%20x64%20Setup.exe 注册信息:sublime t ...

  6. [转]关于vs2005、vs2008和vs2010项目互转的总结

    关于vs2005.vs2008和vs2010项目互转的总结 分类: Asp.Net2010-11-16 16:59 18239人阅读 评论(12) 收藏 举报 2010.net框架编译器 有做.net ...

  7. js中级总结

    this问题: this是JavaScript的关键字      用途:指向某一个对象 如何判断this的指向 函数内:两种情况:1.以函数形式调用(不带 . 指向window ) 2.以方法形式调用 ...

  8. latex 入门及使用

    latex 入门及使用 LaTeX新人教程,30分钟从完全陌生到基本入门 >> vim test.tex \documentclass[11pt,twoside,a4paper]{arti ...

  9. [转载]Deep Learning(深度学习)学习笔记整理

    转载自:http://blog.csdn.net/zouxy09/article/details/8775360 感谢原作者:zouxy09@qq.com 八.Deep learning训练过程 8. ...

  10. VMware中,该如何理解桥接网络与NAT 网络模式

    原创 2016年11月16日 23:26:34,原文地址如下: http://blog.csdn.net/u010801439/article/details/53193113 首先,我在VMware ...