本文整理了Java中org.hibernate.SessionFactory.close()
方法的一些代码示例,展示了SessionFactory.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SessionFactory.close()
方法的具体详情如下:
包路径:org.hibernate.SessionFactory
类名称:SessionFactory
方法名:close
[英]Destroy this SessionFactory and release all resources (caches, connection pools, etc).
It is the responsibility of the application to ensure that there are no open Session before calling this method as the impact on those Session is indeterminate.
No-ops if already #isClosed.
[中]销毁此SessionFactory并释放所有资源(缓存、连接池等)。
应用程序有责任确保在调用此方法之前没有打开的会话,因为对这些会话的影响是不确定的。
如果已经关闭,就不要行动。
代码示例来源:origin: spring-projects/spring-framework
@Override
public void destroy() {
if (this.sessionFactory != null) {
this.sessionFactory.close();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void ungetService(Bundle requestingBundle, ServiceRegistration registration, Object service) {
((SessionFactory) service).close();
}
代码示例来源:origin: hibernate/hibernate-orm
public void clearRegistrations() {
nameUuidXref.clear();
for ( SessionFactory factory : sessionFactoryMap.values() ) {
try {
factory.close();
}
catch (Exception ignore) {
}
}
sessionFactoryMap.clear();
}
代码示例来源:origin: dropwizard/dropwizard
@Override
public void stop() throws Exception {
factory.close();
dataSource.stop();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void stop() {
sessionFactory.close();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@After
public void afterTest() {
if ( sf != null ) {
sf.close();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@After
public void tearDown() {
sessionFactory.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@AfterClassOnce
public void destroy() {
sessionFactory.close();
for ( ConnectionProvider connectionProvider : connectionProviderMap.values() ) {
if ( connectionProvider instanceof Stoppable ) {
( (Stoppable) connectionProvider ).stop();
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@AfterClassOnce
public void destroy() {
sessionFactory.close();
for ( ConnectionProvider connectionProvider : connectionProviderMap.values() ) {
if ( connectionProvider instanceof Stoppable ) {
( (Stoppable) connectionProvider ).stop();
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testDrop() throws Exception {
final SessionFactory sessionFactory = buildSessionFactory();
sessionFactory.close();
}
@Test
代码示例来源:origin: hibernate/hibernate-orm
@AfterClassOnce
public void closeSessionFactory() {
try {
sessionFactory.close();
}
finally {
if ( serviceRegistry != null ) {
ServiceRegistryBuilder.destroy( serviceRegistry );
serviceRegistry = null;
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@After
public void tearDown() {
if(sessionFactory !=null) sessionFactory.close();
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testDropDuringActiveJtaTransaction() throws Exception {
final SessionFactory sessionFactory = buildSessionFactory();
JtaPlatformStandardTestingImpl.INSTANCE.transactionManager().begin();
try {
sessionFactory.close();
}
finally {
JtaPlatformStandardTestingImpl.INSTANCE.transactionManager().commit();
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testQuery() {
Configuration cfg = new Configuration();
cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
cfg.addInputStream(new ReaderInputStream(new StringReader(NAMED_QUERY_HBM_XML)));
SessionFactory sessionFactory = cfg.buildSessionFactory();
sessionFactory.close();
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Tests that nothing crazy happens if the hibernate-envers jar happens
* to be on the classpath but we have no audited entities
*/
@Test
@TestForIssue( jiraKey = "HHH-9675" )
public void testNoAudited() {
new Configuration().buildSessionFactory().close();
new Configuration().addAnnotatedClass( SimpleNonAuditedEntity.class ).buildSessionFactory().close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testFirstTypeThenEntity(){
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml")
.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml");
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
Assert.assertNotNull(sessions);
sessions.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testFirstEntityThenType(){
cfg.addResource("org/hibernate/test/mapping/usertypes/TestEntity.hbm.xml")
.addResource("org/hibernate/test/mapping/usertypes/TestEnumType.hbm.xml");
SessionFactory sessions=cfg.buildSessionFactory(serviceRegistry);
Assert.assertNotNull(sessions);
sessions.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-8167" )
public void testAnnotatedFormWithBeanValidationNotNull() {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass( AnnotatedMaster.class ).addAnnotatedClass( AnnotatedDetail.class );
cfg.buildSessionFactory().close();
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void buildSessionFactory(Class<?> entity) {
StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build();
try {
new MetadataSources( serviceRegistry )
.addAnnotatedClass( entity )
.buildMetadata()
.buildSessionFactory()
.close();
}
finally {
StandardServiceRegistryBuilder.destroy( serviceRegistry );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-9897" )
@FailureExpected( jiraKey = "HHH-9897" )
public void testUseOfJoinColumnOrFormula() {
Metadata metadata = new MetadataSources()
.addAnnotatedClass( A.class )
.addAnnotatedClass( D.class )
.buildMetadata();
// Binding to the mapping model works after the simple change for HHH-9897
// But building the SessionFactory fails in the collection persister trying to
// use the formula (it expects Columns too)
metadata.buildSessionFactory().close();
}
内容来源于网络,如有侵权,请联系作者删除!