Hibernate 错误和异常,无法生成hbm.xml、SessionFactory报空....
来源:互联网 发布:sql查询语句表别名 编辑:程序博客网 时间:2024/06/06 00:25
Hibernate 测试连接数据库时,报 transaction 空指针异常 等错误。
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set..Configured SessionFactory: null
这是因为在hibernate4中已经把原有的SessionFactory sessions = cfg.buildSessionFactory();
这种方法标记为过时的了。
在hibernate4中,构建 SessionFactory 需要加入参数ServiceRegistry。
原来的代码:
/*错误的配置,一开始有效*/ //创建配置对象 Configuration config = new Configuration().configure(); //创建服务注册对象 StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder().configure().build(); //创建会话工厂对象 sessionFactory =config.buildSessionFactory(standardRegistry);
修改的代码:
private SessionFactory sessionFactory; private Session session; private Transaction transaction; . . //创建配置对象 Configuration cfg = new Configuration().configure(); //创建服务注册对象 StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() .applySettings(cfg.getProperties()).build(); //创建会话工厂对象 sessionFactory = cfg.buildSessionFactory(serviceRegistry);
头信息版本问题无法生成关系映射文件 hbm.xml文件
JBoss Tools 4.4.1 Final
Eclipse Neon.1a Release (4.6.1)
Hibernate 版本是4.3.11
在我的测试中,如果你的Eclipse还没有自动生成过hibernate.cfg.xml,就不能通过JBoss工具自动生成hbm.xml文件,而且hibernate.cfg.xml头信息只能写3.0的版本,我新装的Eclipse就是这样
错误:
Unable to create requested service [org.hibernate.engine.spi.CacheImple..
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEn
注意hibernate.cfg.xml
文件前缀,
3.0,这个版本可以通过jboss自动生成 hbm.xml,4.0不行,反正,cfg.xml,自动生成更好
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
4.0
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration" xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
NoClassDefFoundError: com/mchange/v2/ser/Indirector
Failed to instantiate [com.mchange.v2.c3p0.ComboPooledDataSource]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
没有引入mchange-commons-java-0.2.3.4.jar
这个包
HQL语句异常
node to traverse cannot be null
from 实体类名 where ...
from 要写对,from后不能跟表名,而是实体类的类名,否则会说不能maping什么的
$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
cn.....domain.某个类_$$_javassist_0 cannot be cast to javassist.util.proxy.Proxy
包冲突了,hibernate和strus都有javassist-XX.jar这个包只需要导入一个就可以了
0 0
- Hibernate 错误和异常,无法生成hbm.xml、SessionFactory报空....
- 自动生成hibernate.hbm.xml
- 利用Hibernate Tool 连接数据库, 生成java和hbm.xml
- [Hibernate]使用XDoclet生成hbm.xml
- [Hibernate]使用XDoclet生成hbm.xml
- [Hibernate]使用XDoclet生成hbm.xml
- [Hibernate]使用XDoclet生成hbm.xml
- 解决插件 Hibernate for Eclipse生成的hbm.xml 无法显示中文问题
- hibernate.cfg.xml和.hbm.xml
- Event.hbm.xml和hibernate.cfg.xml
- Hibernate Tools-代码生成cfg.xml,hbm.xml和持久類
- Hibernate--Session session = sessionFactory.getCurrentSession()空指针异常
- hibernate4的cfg.cml文件和hbm.xml文件无法读取报错
- Hibernate API和.hbm.xml映射教程
- Hibernate逆向生成class和hbm映射
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件
- myeclipse中如何自动生成hibernate得POJO和hbm.xml文件
- 通过MyEclipse生成Hibernate类文件和hbm.xml文件,或者annotation文件
- Jsoup解析Html中文文档
- Android判断用户名只能为字母、数字和汉字
- spring mvc项目使用form表单上传文件
- apt-get 与 yum的区别 (转)
- 经典SQL语句——基础篇
- Hibernate 错误和异常,无法生成hbm.xml、SessionFactory报空....
- DSP优化,通用的调整性能的策略 .
- linux压缩和解压缩
- 把数组排成最小的数
- HDU 4055 Number String
- HBase shell常用命令
- Android笔记之自定义View——绘制圆环比例展示图
- centOS6.5下安装redis扩展
- embed和video的使用