Code example for Session

Methods: closedeletebeginTransactioncreateCriteriagetTransaction

0
		assertEquals( sessionFactory().getStatistics().getQueryCachePutCount(), 1 ); 
 
		sessionFactory().getStatistics().clear(); 
 
		s = openSession();
		s.beginTransaction();
		u = ( User ) s.createCriteria( User.class )
				.add( Restrictions.naturalId().set( "userName", "steve" ) )
				.setCacheable( true )
				.uniqueResult();
		assertNotNull( u );
		assertEquals( sessionFactory().getStatistics().getQueryExecutionCount(), 0 ); 
		assertEquals( sessionFactory().getStatistics().getQueryCacheHitCount(), 1 ); 
 
		s.delete( u );
 
		s.getTransaction().commit();
		s.close();
 
		s = openSession();
		s.beginTransaction();
		u = ( User ) s.createCriteria( User.class )
				.add( Restrictions.naturalId().set( "userName", "steve" ) )
Contextual code suggestions in your IDE  Get Codota for Java