hibernate错误整理

问题1could  not  get constructor for org hibernate persister entity single table entity persister

解决办法:

1检查实体类是否有默认的无参构造函数

2.导入相关的jar包(hibernate-entitymanager-4.3.11.Final.jar,hibernate-jpamodelgen-4.3.11.Final.jar)

3.查找你的实体类的类型是否与hbm.xml 的类型相符合

4. 查找你的实体类的类型是否与hbm.xml 的属性名字相符合

问题2connection be null when hibernate.dialect not set

解决办法:

  1. Configuration config = new Configuration().configure();检查配置时与这句话对比
  2. 设置方言和你数据库一样的方言

问题3

<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property>

这句话引起的异常

这句话的意思是设置用的jdbc处理不是jta

解决办法:

  1. 在org.hibernate.cache包下面缺少很多class文件,如HashtableCacheProvider.class等,你可以将hibernate3中org.hibernate.cache下面的文件拷贝到hibernate4的核心jar包下,或者使用Hibernate3的核心jar包。
  2. 删除这句话,使用默认的

问题 4error activating bean validation integration

解决办法:

1.加载的类的位置是否正确

问题5 :expected <true> but was<false>

解决办法

1

定义了 Transaction

却没有开启

   tx=session.beginTransaction();

2.重复提交事务(删掉多余的就好了)

原文地址:https://www.cnblogs.com/thehugo/p/5616856.html