Hibernate-core 4.3.6 Final 配置中出现的一些小问题
来源:互联网 发布:cad仿真软件 编辑:程序博客网 时间:2024/06/06 01:53
毕竟hibernate是有名的ORM框架,所以还是学着用一用,结果还是出了不少问题,文档啊文档,你就不能及时更新么。
首先在创建一个全局的SessionFactory中,文档中的示例代码是这样的,但这个是不能成功运行的,需要在try块中稍微改一下
public class HibernateUtil { private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { // Create the SessionFactory from hibernate.cfg.xml new Configuration().configure().buildSessionFactory( new StandardServiceRegistryBuilder().build() ); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; }}
Configuration config = new Configuration();config.configure("hibernate.cfg.xml"); // 这里还是指定一下要不然会先去找hibernate.propertiesreturn config.buildSessionFactory(new StandardServiceRegistryBuilder() .applySettings(config.getProperties()).build()); // 主要多加了一个applySettings
然后在启动的时候还会抛一个错
九月 17, 2014 9:29:52 下午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
在下面这个网站可以看这部分的源码
http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/4.3.6.Final/org/hibernate/engine/jdbc/internal/LobCreatorBuilder.java#LobCreatorBuilder.useContextualLobCreation%28java.util.Map%2Cjava.sql.Connection%29
其中的注释是这样说的
Basically here we are simply checking whether we can call the java.sql.Connection methods for LOB creation added in JDBC 4. We not only check whether the java.sql.Connection declares these methods, but also whether the actual java.sql.Connection instance implements them (i.e. can be called without simply throwing an exception).
也就是说,这个错误应该是hibernate检测到mysql-connector-java(5.1.31)没有实现这个接口。
也看到有人说http://my.oschina.net/huangchp/blog/205461
使用mysql-connector-java 5.1.13及以下版本可以解决,但具体原因还不知道
感觉应该是这个原因了,不过暂时不影响使用就先不管了
- Hibernate-core 4.3.6 Final 配置中出现的一些小问题
- 用Hibernate hibernate-release-4.1.0.Final出现的一些问题
- 关于ssh 框架 applicationContext.xml文件中配置hibernate数据库出现的一个小问题
- hibernate的一些小问题
- Spring 与hibernate整合过程中出现的一些问题
- VC中出现的一些小问题的解决办法
- VC中出现的一些小问题的解决办法
- jdbc访问数据库中出现的一些小问题 ing...
- 在hibernate中配置many-to-one出现的问题
- hibernate jpa 4.0.3 final 的一些问题
- CORE DATA 中遇到的一些问题
- Hibernate 4.3.5.Final的orderColumn问题
- Java出现的一些小问题
- hibernate配置二级缓存出现的问题
- Hibernate配置注意的一些问题
- jboss配置出现的一个小问题
- 关于java中final变量的小问题
- Hibernate Core 4.0 Final 发布
- grunt-contrib-connect使用心得
- gulp plugin开发
- Gulp思维——Gulp高级技巧
- 关于嵌入式, 知乎上的一些回答
- Hello, world!_0
- Hibernate-core 4.3.6 Final 配置中出现的一些小问题
- How to fix 远程计算机需要网络级别身份验证 when using mstsc on XP
- HTML5 本地裁剪图片并上传至服务器(老梗)
- HTTP入门笔记
- idea hadoop 开发环境
- Intellij IDEA 13 注册码
- iOS CoreAnimation 简单动画的使用
- iOS 瀑布流的实现方法
- IOS 自适应元素 NSLayoutConstraint