Hibernate 4中的SessionFactory.openSession(Connection)

龙:

我正在使用抽送现有的JDBC连接SessionFactory.openSession(Connection)现在在4.0中,此方法不可用。我应该使用哪种方法?

小贴士:

您可以使用SessionFactory.withOptions()SessionBuilder.connection(Connection connection)

SessionBuilder连接(连接连接)

将特定的连接添加到会话选项

参数connection-要使用的连接。

返回:此,用于方法链接

例:

SessionBuilder sb = SessionFactory.withOptions();
Session session = sb.connection(connection).openSession();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Hibernate的Sessionfactory.getCurrentSession()和SessionFactory.openSession()的区别

Hibernate 4在Abstract Factory中创建sessionfactory

java.lang.NoSuchMethodError:org.hibernate.SessionFactory.openSession()Lorg / hibernate / classic / Session

Hibernate OpenSession()与GetCurrentSession()

hibernate SessionFactory.openSession()是否等待池中的数据库连接可用

Spring 3.1,Hibernate 4,SessionFactory

Spring 4 + Hibernate 4:sessionFactory为空

在Hibernate中使用SessionFactory.getCurrentSession()时获取Connection对象

休眠,sessionFactory.openSession挂起

在hibernate5.1和spring 4.1.6集成中找不到Hibernatetemplate的opensession()异常

Spring / Hibernate集成中的NPE SessionFactory

Hibernate 3 sessionFactory在Spring Java配置中

Hibernate SessionFactory与Spring LocalSessionFactoryBean

Hibernate SessionFactory与JPA EntityManagerFactory

Hibernate + Spring SessionFactory配置

如何在Spring Boot中自动连接Hibernate SessionFactory

sessionfactory 在基于 Spring hibernate xml 的配置中总是返回 null

sessionFactory与HttpSession之间的区别?在Spring + Hibernate应用程序中?

休眠:sessionFactory.openSession()VS sessionFactory.getCurrentSession()

sessionfactory.openSession()和sessionfactory.openStatelessSession()之间的区别?

使用hibernate sessionFactory还是JPAEntityManager?

Hibernate SessionFactory,动态设置TransactionIsolationLevel

Hibernate初始SessionFactory创建失败

获取文件路径-Hibernate SessionFactory

Hibernate中的Session和Connection有什么区别?

Netty / Armeria处理程序方法中的Bootstrap Hibernate SessionFactory失败,并出现ClassNotFoundException

PersistenceException中的模棱两可的消息:无法建立Hibernate SessionFactory

为什么在Spring-Hibernate Configuration中同时配置dataSource和sessionFactory?

Hibernate 5.x + Spring 5.x,无法自动装配DAOImpl类中的SessionFactory