Code example for Session

Methods: closecontainsdeletesaveOrUpdatebeginTransactioncreateCriteria

0
		s.close();
 
		clearCounts(); 
 
		s = openSession();
		tx = s.beginTransaction();
		Node child = new Node( "child" ); 
		root.addChild( child ); 
		s.saveOrUpdate( root );
		assertTrue( s.contains( child ) );
		tx.commit();
 
		assertInsertCount( 1 ); 
		assertUpdateCount( 1 ); //note: will fail here if no second-level cache 
 
		tx = s.beginTransaction();
		assertEquals( 
				s.createCriteria( Node.class )
						.setProjection( Projections.rowCount() )
						.uniqueResult(), 
		        new Long( 2 )
		); 
		s.delete( root );
		s.delete( child );
		tx.commit();
		s.close();
	} 
 
	@Test
	public void testEvictThenSaveOrUpdate() { 
		Session s = openSession();