@Override public void close() throws HibernateException { delegate.close(); }
protected void rebuildSessionFactory(Consumer<Configuration> configurationAdapter) { if ( sessionFactory == null ) { return; } try { sessionFactory.close(); sessionFactory = null; configuration = null; serviceRegistry.destroy(); serviceRegistry = null; } catch (Exception ignore) { } buildSessionFactory( configurationAdapter ); }
@After public void releaseSessionFactory() { if ( sessionFactory != null ) { sessionFactory.close(); } }
@After public void releaseResources() { if ( sessionFactory != null ) { sessionFactory.close(); } }
@AfterClass public static void closeSessionFactory() { if ( SESSION_FACTORY != null ) { SESSION_FACTORY.close(); SESSION_FACTORY = null; } }
@Test public void testAccessOnAssociationXmlElement() throws Exception { Class<?> classUnderTest = RentalCar.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); classes.add( Driver.class ); List<String> configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/RentalCar.xml" ); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.PROPERTY ); factory.close(); }
@Test public void testAccessOnEmbeddedXmlElement() throws Exception { Class<?> classUnderTest = Cook.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); classes.add( Knive.class ); List<String> configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/Cook.xml" ); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.PROPERTY ); factory.close(); }
@Test public void testAccessOnElementCollectionXmlElement() throws Exception { Class<?> classUnderTest = Boy.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); List<String> configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/Boy.xml" ); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.PROPERTY ); factory.close(); }
@Test public void testAccessOnMappedSuperClassXmlElement() throws Exception { Class<?> classUnderTest = Waiter.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); classes.add( Crew.class ); List<String> configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/Crew.xml" ); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.FIELD ); factory.close(); }
@After public void destroy() { sessionFactory.close(); connectionProvider.stop(); }
@AfterClassOnce public void releaseEntityManagerFactory() { if ( entityManagerFactory != null && entityManagerFactory.isOpen() ) { entityManagerFactory.close(); } }
@After @SuppressWarnings("unused") public void releaseResources() { if ( sessionFactory != null ) { sessionFactory.close(); } if ( serviceRegistry != null ) { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } }
@After public void tearDown() throws Exception { if ( sessionFactory != null ) { sessionFactory.close(); } if ( serviceRegistry != null ) { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } }
@Test public void testAccessOnBasicXmlElement() throws Exception { Class<?> classUnderTest = Tourist.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); List<String> configFiles = Collections.emptyList(); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); // without any xml configuration we have field access assertAccessType( factory, classUnderTest, AccessType.FIELD ); factory.close(); // now with an additional xml configuration file changing the default access type for Tourist using basic configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/Tourist.xml" ); factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.PROPERTY ); factory.close(); }
@Test public void testAccessOnEntityMappingsXmlElement() throws Exception { Class<?> classUnderTest = Tourist.class; List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add( classUnderTest ); List<String> configFiles = Collections.emptyList(); SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles ); // without any xml configuration we have field access assertAccessType( factory, classUnderTest, AccessType.FIELD ); factory.close(); // now with an additional xml configuration file changing the default access type for Tourist using default in entity-mappings configFiles = new ArrayList<String>(); configFiles.add( "org/hibernate/test/annotations/access/xml/Tourist3.xml" ); factory = buildSessionFactory( classes, configFiles ); assertAccessType( factory, classUnderTest, AccessType.PROPERTY ); factory.close(); }
@After public void tearDown() throws Exception { if ( sessionImpl != null && !sessionImpl.isClosed() ) { ((Session) sessionImpl).close(); } if ( sessionFactory != null ) { sessionFactory.close(); } if ( serviceRegistry != null ) { StandardServiceRegistryBuilder.destroy( serviceRegistry ); } }
/** * Sort of the inverse test of {@link MissingCacheStrategyTest#testMissingCacheStrategyFail()}. * Here building the SF should succeed. */ @Test public void testPreDefinedCachesAllowed() { TestHelper.preBuildAllCaches(); SessionFactoryImplementor sessionFactory = TestHelper.buildStandardSessionFactory(); sessionFactory.close(); }
@Test public void test() { sessionFactory().close(); buildSessionFactory(); }
@After public void cleanupData() { if ( sessionFactory == null ) { return; } inTransaction( sessionFactory, s -> { s.createQuery( "delete from Person" ).executeUpdate(); } ); sessionFactory.close(); }
@After public void tearDown() { if ( sessionFactory != null ) { sessionFactory.close(); } if ( serviceRegistry != null ) { serviceRegistry.destroy(); } if ( jbossProvider != null ) { jbossProvider.stop(); } if ( acmeProvider != null ) { acmeProvider.stop(); } }