简体   繁体   English

Hibernate 4中的SessionFactory.openSession(Connection)

[英]SessionFactory.openSession(Connection) in Hibernate 4

I am pumping existing JDBC connection using SessionFactory.openSession(Connection) . 我正在使用SessionFactory.openSession(Connection)来抽取现有的JDBC连接。 Now in 4.0 this method is not available. 现在在4.0中,此方法不可用。 Which method should I use for this? 我应该使用哪种方法?

You can use SessionFactory.withOptions() and SessionBuilder.connection(Connection connection) . 您可以使用SessionFactory.withOptions()SessionBuilder.connection(连接连接)

SessionBuilder connection(Connection connection) SessionBuilder连接(连接连接)

Adds a specific connection to the session options 添加到会话选项的特定连接

Parameters : connection - The connection to use. 参数connection - 要使用的连接。

Returns : this, for method chaining 返回 :this,用于方法链接

Example: 例:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 休眠,sessionFactory.openSession挂起 - Hibernate, sessionFactory.openSession is hanging Hibernate sessionFactory.openSession()返回null - Hibernate sessionFactory.openSession() returns null sessionFactory.openSession中的NullPointerException - NullPointerException in sessionFactory.openSession 休眠:sessionFactory.openSession()与sessionFactory.getCurrentSession() - Hibernate: sessionFactory.openSession() VS sessionFactory.getCurrentSession() 休眠 SessionFactory.openSession() 是否等待池中的数据库连接可用 - Does hibernate SessionFactory.openSession() wait for a database connection to be available from pool Hibernate 4.0.0Final在哪里是SessionFactory.openSession(拦截器拦截器) - Hibernate 4.0.0Final where is the SessionFactory.openSession(Interceptor interceptor) 黑白 Hibernate 的 Sessionfactory.getCurrentSession() 和 SessionFactory.openSession() 的区别 - Difference b/w Hibernate's Sessionfactory.getCurrentSession() and SessionFactory.openSession() sessionfactory.openSession()和sessionfactory.openStatelessSession()之间的区别? - difference between sessionfactory.openSession() and sessionfactory.openStatelessSession()? SessionFactory.openSession()和SessionFactory.getCurrentTransaction()。commit()之间的区别 - Difference between SessionFactory.openSession() & SessionFactory.getCurrentTransaction().commit() NoSuchMethodError:org.hibernate.SessionFactory.openSession() - NoSuchMethodError: org.hibernate.SessionFactory.openSession()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM