本文整理汇总了Java中org.hibernate.internal.SessionFactoryImpl.getConnectionProvider方法的典型用法代码示例。如果您正苦于以下问题:Java SessionFactoryImpl.getConnectionProvider方法的具体用法?Java SessionFactoryImpl.getConnectionProvider怎么用?Java SessionFactoryImpl.getConnectionProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.internal.SessionFactoryImpl
的用法示例。
在下文中一共展示了SessionFactoryImpl.getConnectionProvider方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeFactory
import org.hibernate.internal.SessionFactoryImpl; //导入方法依赖的package包/类
public void closeFactory() { // shutdown persistence engine
if (factory != null) {
if (factory instanceof SessionFactoryImpl) {
SessionFactoryImpl sf = (SessionFactoryImpl) factory;
ConnectionProvider conn = sf.getConnectionProvider();
if (conn instanceof C3P0ConnectionProvider) {
((C3P0ConnectionProvider)conn).stop();
}
}
factory.close();
}
}
示例2: closeFactory
import org.hibernate.internal.SessionFactoryImpl; //导入方法依赖的package包/类
public void closeFactory() {
if (_factory != null) {
if (_factory instanceof SessionFactoryImpl) {
SessionFactoryImpl sf = (SessionFactoryImpl) _factory;
ConnectionProvider conn = sf.getConnectionProvider();
if (conn instanceof C3P0ConnectionProvider) {
((C3P0ConnectionProvider)conn).stop();
}
}
_factory.close();
}
}
示例3: getDefaultDataSource
import org.hibernate.internal.SessionFactoryImpl; //导入方法依赖的package包/类
/**
* Get Default DataSource. JNDI name of datasource is taken from Entity Manager
*
* @return
* @throws NamingException
*/
public static DataSource getDefaultDataSource(EntityManager em) throws NamingException {
// Doesn't work because of https://hibernate.atlassian.net/browse/HHH-8121
// EntityManagerFactory emFactory = em.getEntityManagerFactory();
// Object ds = emFactory.getProperties().get("javax.persistence.jtaDataSource");
// InitialContext initialContext = new InitialContext();
// Object lookup = initialContext.lookup(ds.toString());
// return (DataSource) lookup;
// TODO: Find better way how to get DataSource from JPA without using hard coded JNDI name or casting to JPA implementation
SessionFactoryImpl factory = (SessionFactoryImpl) em.unwrap(Session.class).getSessionFactory(); // or directly cast the sessionFactory
DatasourceConnectionProviderImpl provider = (DatasourceConnectionProviderImpl) factory.getConnectionProvider();
return provider.getDataSource();
}
示例4: getConnectionProvider
import org.hibernate.internal.SessionFactoryImpl; //导入方法依赖的package包/类
public DriverManagerConnectionProviderImpl getConnectionProvider() {
SessionFactoryImpl factory = (SessionFactoryImpl) em.unwrap(Session.class).getSessionFactory();
return (DriverManagerConnectionProviderImpl) factory.getConnectionProvider();
}