Java Code Examples for org.hibernate.Hibernate#close()
The following examples show how to use
org.hibernate.Hibernate#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernateTemplate.java From spring-analysis-note with MIT License | 5 votes |
@Deprecated @Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 2
Source File: HibernateTemplate.java From java-technology-stack with MIT License | 5 votes |
@Deprecated @Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 3
Source File: HibernateTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 4
Source File: HibernateTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 5
Source File: HibernateTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 6
Source File: HibernateTemplate.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 7
Source File: HibernateTemplate.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 8
Source File: HibernateTemplate.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void closeIterator(Iterator<?> it) throws DataAccessException { try { Hibernate.close(it); } catch (HibernateException ex) { throw SessionFactoryUtils.convertHibernateAccessException(ex); } }
Example 9
Source File: AggressiveReleaseTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void testQueryIteration() throws Throwable { prepare(); Session s = getSessionUnderTest(); Silly silly = new Silly( "silly" ); s.save( silly ); s.flush(); Iterator itr = s.createQuery( "from Silly" ).iterate(); assertTrue( itr.hasNext() ); Silly silly2 = ( Silly ) itr.next(); assertEquals( silly, silly2 ); Hibernate.close( itr ); itr = s.createQuery( "from Silly" ).iterate(); Iterator itr2 = s.createQuery( "from Silly where name = 'silly'" ).iterate(); assertTrue( itr.hasNext() ); assertEquals( silly, itr.next() ); assertTrue( itr2.hasNext() ); assertEquals( silly, itr2.next() ); Hibernate.close( itr ); Hibernate.close( itr2 ); s.delete( silly ); s.flush(); release( s ); done(); }
Example 10
Source File: StatsTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void testQueryStatGathering() { Statistics stats = getSessions().getStatistics(); stats.clear(); Session s = openSession(); Transaction tx = s.beginTransaction(); fillDb(s); tx.commit(); s.close(); s = openSession(); tx = s.beginTransaction(); final String continents = "from Continent"; int results = s.createQuery( continents ).list().size(); QueryStatistics continentStats = stats.getQueryStatistics( continents ); assertNotNull( "stats were null", continentStats ); assertEquals( "unexpected execution count", 1, continentStats.getExecutionCount() ); assertEquals( "unexpected row count", results, continentStats.getExecutionRowCount() ); long maxTime = continentStats.getExecutionMaxTime(); assertEquals( maxTime, stats.getQueryExecutionMaxTime() ); // assertEquals( continents, stats.getQueryExecutionMaxTimeQueryString() ); Iterator itr = s.createQuery( continents ).iterate(); // iterate() should increment the execution count assertEquals( "unexpected execution count", 2, continentStats.getExecutionCount() ); // but should not effect the cumulative row count assertEquals( "unexpected row count", results, continentStats.getExecutionRowCount() ); Hibernate.close( itr ); ScrollableResults scrollableResults = s.createQuery( continents ).scroll(); // same deal with scroll()... assertEquals( "unexpected execution count", 3, continentStats.getExecutionCount() ); assertEquals( "unexpected row count", results, continentStats.getExecutionRowCount() ); scrollableResults.close(); tx.commit(); s.close(); // explicitly check that statistics for "split queries" get collected // under the original query stats.clear(); s = openSession(); tx = s.beginTransaction(); final String localities = "from Locality"; results = s.createQuery( localities ).list().size(); QueryStatistics localityStats = stats.getQueryStatistics( localities ); assertNotNull( "stats were null", localityStats ); // ...one for each split query assertEquals( "unexpected execution count", 2, localityStats.getExecutionCount() ); assertEquals( "unexpected row count", results, localityStats.getExecutionRowCount() ); maxTime = localityStats.getExecutionMaxTime(); assertEquals( maxTime, stats.getQueryExecutionMaxTime() ); // assertEquals( localities, stats.getQueryExecutionMaxTimeQueryString() ); tx.commit(); s.close(); assertFalse( s.isOpen() ); // native sql queries stats.clear(); s = openSession(); tx = s.beginTransaction(); final String sql = "select id, name from Country"; results = s.createSQLQuery( sql ).addEntity( Country.class ).list().size(); QueryStatistics sqlStats = stats.getQueryStatistics( sql ); assertNotNull( "sql stats were null", sqlStats ); assertEquals( "unexpected execution count", 1, sqlStats.getExecutionCount() ); assertEquals( "unexpected row count", results, sqlStats.getExecutionRowCount() ); maxTime = sqlStats.getExecutionMaxTime(); assertEquals( maxTime, stats.getQueryExecutionMaxTime() ); // assertEquals( sql, stats.getQueryExecutionMaxTimeQueryString() ); tx.commit(); s.close(); s = openSession(); tx = s.beginTransaction(); cleanDb( s ); tx.commit(); s.close(); }