use of org.hibernate.engine.spi.SessionFactoryImplementor in project uPortal by Jasig.
the class DataSourceSchemaExport method setConfiguration.
@Override
public void setConfiguration(String persistenceUnit, HibernateConfiguration hibernateConfiguration) {
this.configuration = hibernateConfiguration.getConfiguration();
final SessionFactoryImplementor sessionFactory = hibernateConfiguration.getSessionFactory();
this.dialect = sessionFactory.getDialect();
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project spring-framework by spring-projects.
the class SessionFactoryUtils method getDataSource.
/**
* Determine the DataSource of the given SessionFactory.
* @param sessionFactory the SessionFactory to check
* @return the DataSource, or {@code null} if none found
* @see ConnectionProvider
*/
public static DataSource getDataSource(SessionFactory sessionFactory) {
Method getProperties = ClassUtils.getMethodIfAvailable(sessionFactory.getClass(), "getProperties");
if (getProperties != null) {
Map<?, ?> props = (Map<?, ?>) ReflectionUtils.invokeMethod(getProperties, sessionFactory);
Object dataSourceValue = props.get(Environment.DATASOURCE);
if (dataSourceValue instanceof DataSource) {
return (DataSource) dataSourceValue;
}
}
if (sessionFactory instanceof SessionFactoryImplementor) {
SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory;
try {
ConnectionProvider cp = sfi.getServiceRegistry().getService(ConnectionProvider.class);
if (cp != null) {
return cp.unwrap(DataSource.class);
}
} catch (UnknownServiceException ex) {
if (logger.isDebugEnabled()) {
logger.debug("No ConnectionProvider found - cannot determine DataSource for SessionFactory: " + ex);
}
}
}
return null;
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class OsgiIntegrationTest method testServiceContributorDiscovery.
@Test
public void testServiceContributorDiscovery() throws Exception {
final ServiceReference sr = bundleContext.getServiceReference(SessionFactory.class.getName());
final SessionFactoryImplementor sfi = (SessionFactoryImplementor) bundleContext.getService(sr);
assertNotNull(sfi.getServiceRegistry().getService(SomeService.class));
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class OsgiIntegrationTest method testExtensionPoints.
@Test
public void testExtensionPoints() throws Exception {
final ServiceReference sr = bundleContext.getServiceReference(SessionFactory.class.getName());
final SessionFactoryImplementor sfi = (SessionFactoryImplementor) bundleContext.getService(sr);
assertTrue(TestIntegrator.passed());
Class impl = sfi.getServiceRegistry().getService(StrategySelector.class).selectStrategyImplementor(Calendar.class, TestStrategyRegistrationProvider.GREGORIAN);
assertNotNull(impl);
BasicType basicType = sfi.getTypeResolver().basic(TestTypeContributor.NAME);
assertNotNull(basicType);
}
use of org.hibernate.engine.spi.SessionFactoryImplementor in project hibernate-orm by hibernate.
the class SpatialRelateExpression method toSqlString.
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
final SessionFactoryImplementor factory = criteriaQuery.getFactory();
final String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, this.propertyName);
final Dialect dialect = factory.getDialect();
if (dialect instanceof SpatialDialect) {
final SpatialDialect seDialect = (SpatialDialect) dialect;
return seDialect.getSpatialRelateSQL(columns[0], spatialRelation);
} else {
throw new IllegalStateException("Dialect must be spatially enabled dialect");
}
}
Aggregations