Hibernate关系映射时出现的问题
2018-01-19 21:09
381 查看
在学习Hibernate框架的关系映射时,遇到了一个问题:
INFO: HHH000422: Disabling contextual LOB creation as connection was null
在网上找了一下原因,以下是网上找的原文:
毕竟hibernate是有名的ORM框架,所以还是学着用一用,结果还是出了不少问题,文档啊文档,你就不能及时更新么。
首先在创建一个全局的SessionFactory中,文档中的示例代码是这样的,但这个是不能成功运行的,需要在try块中稍微改一下
public class HibernateUtil {
}
Configuration config = new Configuration();
config.configure(“hibernate.cfg.xml”); // 这里还是指定一下要不然会先去找hibernate.properties
return 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
其中的注释是这样说的
也就是说,这个错误应该是hibernate检测到mysql-connector-java(5.1.31)没有实现这个接口。
也看到有人说http://my.oschina.net/huangchp/blog/205461
感觉应该是这个原因了,不过暂时不影响使用就先不管了
这里是:原文链接
INFO: HHH000422: Disabling contextual LOB creation as connection was null
在网上找了一下原因,以下是网上找的原文:
毕竟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.properties
return 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的对象-关系映射文件中出现的问题
- Hibernate 中annotations(注解开发)的@OneToMany 一对多双向关联映射后,出现的jar包冲突问题
- 有关Hibernate映射关系 no session or session was closed问题解绝方法
- 解决使用Hibernate QBC复合查询含有联合主键映射关系实体的问题
- Hibernate映射的关系问题
- hibernate自动生成映射文件和java实体类出现的问题
- Hibernate注解映射sequence时出现无序增长问题
- Hibernate注解映射sequence时出现无序增长问题+hibernate 映射 oracle ID自动增长
- 关于hibernate映射继承关系时独立的子类配置文件的问题
- 在使用Hibernate时,因为一个查询需要更多的表连接而要使用SQL来解决性能问题。然而返回的结果集中包含了没有映射的Entity类中的表字段,在这个SQL中还有使用如何将层次关系的父子结点显示为横行
- hibernate属性映射出现could not resolve property问题
- Hibernate注解映射sequence时出现无序增长问题+hibernate 映射 oracle ID自动增长:
- hibernate中两个实体类与同一张数据表进行映射后出现的问题解决
- 关于hibernate的关系映射的问题一些理解和笔记
- SSH框架之Hibernate一对多关系数据绑值修改删除出现问题
- Caused by: org.hibernate.hql.ast.QuerySyntaxException: TkltEmpQuitProcess is not mapped. (SSH项目中出现的映射问题)
- hibernate原生sql查询映射java bean问题,出现Ljava.lang.object错误
- hibernate映射oracle数据表时候出现“ORA-00903: 表名无效”问题
- Hibernate的七种映射关系之七种关联映射
- Hibernate 的七种映射关系