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. jsp渲染

    SP与Servlet什么关系?JSP和ASP什么关系?下面我们一一来探讨. 第一个.jsp文件:<html>    <head>           <title> ...

  2. 如何在 QWidget 窗口上弹出右键菜单

    Title : QWidget 窗口上弹出右键菜单的两个方法 Solution 1 : 给一个 QWidget 添加 QActions,设置 QWidget 的 contextMenuPolicy 属 ...

  3. Python获取当前年月日

    import datetime datetime.datetime.now().year datetime.datetime.now().month datetime.datetime.now().d ...

  4. 小峰mybatis(2)mybatis传入多个参数等..

    一.mybatis传入多个参数: 前面讲传入多个参数都是使用map,hashmap:key value的形式:-- 项目中开发都建议使用map传参: 比如现在通过两个参数,name和age来查询: 通 ...

  5. ActiveMQ 高可用集群安装、配置(ZooKeeper + LevelDB)

    ActiveMQ 高可用集群安装.配置(ZooKeeper + LevelDB) 1.ActiveMQ 集群部署规划: 环境: JDK7 版本:ActiveMQ 5.11.1 ZooKeeper 集群 ...

  6. JVM的DirectMemory设置

    转载http://blog.csdn.net/zshake/article/details/46785469 几台服务器的JVM占用内存总是持续增长,大大超过-Xmx设定的值,服务器物理内存几乎被耗尽 ...

  7. RAID磁盘阵列的原理与搭建

    学习导图 RAID-0结构关系图 RAID-1结构关系图 RAID-5:条带+分布校验(三块磁盘以上) RAID-10:镜像+条带(四块磁盘以上) RAID-0 添加两块硬盘,分别为磁盘1.磁盘2.最 ...

  8. Centos 6.5将光盘作为yum源的设置方法

    Centos 6.5将光盘作为yum源的设置方法 在使用Centos 的时候,用yum来安装软件包是再方便不过了,但是如果在无法连接互联网的情况下,yum就不好用了. 下面介绍一种方式,就是将Cent ...

  9. 服务器开启JMX监控

    JMX是一个框架,提供了一种功能,可以实时查询应用程序中通过JMX向外部公布的相应参数或者是其他应用程序,同时也可以通过JMX来实时地调用应用程序使用JMX向外部公布的接口,来完成一些功能操作. 如果 ...

  10. numpy的where函数

    numpy.where(condition[,x,y]) condition是条件,x,y是可选参数,这三个输入参数都是array_like的形式且三者的维度相同 当conditon的某个位置为tru ...