本文整理了Java中org.hibernate.SessionFactory.getSessionFactoryOptions()
方法的一些代码示例,展示了SessionFactory.getSessionFactoryOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SessionFactory.getSessionFactoryOptions()
方法的具体详情如下:
包路径:org.hibernate.SessionFactory
类名称:SessionFactory
方法名:getSessionFactoryOptions
[英]Get the special options used to build the factory.
[中]获取用于建造工厂的特殊选项。
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testMaxSize() {
doInJPA( this::entityManagerFactory, entityManager -> {
EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();
SessionFactory sessionFactory = entityManagerFactory.unwrap( SessionFactory.class );
assertEquals(
expectedQueryStatisticsMaxSize(),
sessionFactory.getSessionFactoryOptions().getQueryStatisticsMaxSize()
);
StatisticsImplementor statistics = (StatisticsImplementor) sessionFactory.getStatistics();
for ( int i = 0; i < 10; i++ ) {
statistics.queryExecuted( String.valueOf( i ), 100, i * 1000 );
}
assertEquals( 1000, statistics.getQueryStatistics( "1" ).getExecutionTotalTime() );
for ( int i = 100; i < 300; i++ ) {
statistics.queryExecuted( String.valueOf( i ), 100, i * 1000 );
}
assertEquals( 0, statistics.getQueryStatistics( "1" ).getExecutionTotalTime() );
} );
}
}
代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate4-core
@Override
public SessionFactoryOptions getSessionFactoryOptions() {
return delegate.getSessionFactoryOptions();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
@Override
public SessionFactoryOptions getSessionFactoryOptions() {
return impl.getSessionFactoryOptions();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
@Override
public SessionFactoryOptions getSessionFactoryOptions() {
return impl.getSessionFactoryOptions();
}
代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate5-core
@Override
public SessionFactoryOptions getSessionFactoryOptions() {
return delegate.getSessionFactoryOptions();
}
代码示例来源:origin: picocontainer/picocontainer
public SessionFactoryOptions getSessionFactoryOptions() {
return delegate.getSessionFactoryOptions();
}
代码示例来源:origin: org.nuiton.topia/topia-persistence
/**
* Method to extract from the given Hibernate SessionFactory a working instance of StandardServiceRegistry
*
* IMPORTANT : As much as possible, prefer using the
* {@link #getSessionFactoryServiceRegistry(org.hibernate.SessionFactory)} mthod instead of the current one because
* the SessionFactoryServiceRegistry is a child of the StandardServiceRegistry
*
* NB: This method is static to make sure it does not depend on the current instance
*
* @param sessionFactory the Hibernate's SessionFactory instance
* @return the StandardServiceRegistry instance used by the given SessionFactory
*/
public static StandardServiceRegistry getStandardServiceRegistry(SessionFactory sessionFactory) {
// AThimel 03/04/14 The next two lines are the good way to get the StandardServiceRegistry in Hibernate 4.3
SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
StandardServiceRegistry result = sessionFactoryOptions.getServiceRegistry();
return result;
}
代码示例来源:origin: net.oneandone.cosmo/cosmo-core
/**
* Schema validation
*/
// TODO
private void validateSchema() {
try {
SessionFactory factory = this.localSessionFactory.unwrap(SessionFactory.class);
StandardServiceRegistry registry = factory.getSessionFactoryOptions().getServiceRegistry();
MetadataSources sources = new MetadataSources(registry);
sources.addPackage("org.unitedinternet.cosmo.model.hibernate");
Metadata metadata = sources.buildMetadata(registry);
new SchemaValidator().validate(metadata);
LOG.info("schema validation passed");
} catch (HibernateException e) {
LOG.error("error validating schema", e);
throw e;
}
}
}
代码示例来源:origin: hibernate/hibernate-search
sessionService.getSessionFactory().getSessionFactoryOptions().getMultiTenancyStrategy();
this.multitenancyEnabled = !MultiTenancyStrategy.NONE.equals( multitenancyStrategy );
代码示例来源:origin: 1and1/cosmo
/**
* Schema validation
*/
// TODO
private void validateSchema() {
try {
SessionFactory factory = this.localSessionFactory.unwrap(SessionFactory.class);
StandardServiceRegistry registry = factory.getSessionFactoryOptions().getServiceRegistry();
MetadataSources sources = new MetadataSources(registry);
sources.addPackage("org.unitedinternet.cosmo.model.hibernate");
Metadata metadata = sources.buildMetadata(registry);
new SchemaValidator().validate(metadata);
LOG.info("schema validation passed");
} catch (HibernateException e) {
LOG.error("error validating schema", e);
throw e;
}
}
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
public static void withTxSession(boolean useJta, SessionFactory sessionFactory, ThrowingConsumer<Session, Exception> consumer) throws Exception {
JtaPlatform jtaPlatform = useJta ? sessionFactory.getSessionFactoryOptions().getServiceRegistry().getService(JtaPlatform.class) : null;
withTxSession(jtaPlatform, sessionFactory.withOptions(), consumer);
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
public static <T> T withTxSessionApply(boolean useJta, SessionFactory sessionFactory, ThrowingFunction<Session, T, Exception> function) throws Exception {
JtaPlatform jtaPlatform = useJta ? sessionFactory.getSessionFactoryOptions().getServiceRegistry().getService(JtaPlatform.class) : null;
return withTxSessionApply(jtaPlatform, sessionFactory.withOptions(), function);
}
代码示例来源:origin: org.infinispan/infinispan-hibernate-cache-commons
public static void markRollbackOnly(boolean useJta, Session s) {
if (useJta) {
JtaPlatform jtaPlatform = s.getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService(JtaPlatform.class);
TransactionManager tm = jtaPlatform.retrieveTransactionManager();
try {
tm.setRollbackOnly();
} catch (SystemException e) {
throw new RuntimeException(e);
}
} else {
s.getTransaction().markRollbackOnly();
}
}
内容来源于网络,如有侵权,请联系作者删除!