Code example for Session

Methods: clearclosedeleteflushloadbeginTransaction

0
			SkipLog.reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" ); 
			return; 
		} 
 
		s = openSession( new DocumentInterceptor() );
		t = s.beginTransaction();
		Item id = (Item) s.load( Item.class, did );
		assertEquals( did, id.getId() );
		assertEquals( "Hibernate in Action", id.getName() );
		assertEquals( "/", id.getParent().getName() );
 
		Item id2 = (Item) s.load( Item.class, d2id );
		assertEquals( d2id, id2.getId() );
		assertEquals( "Secret", id2.getName() );
		assertEquals( "/", id2.getParent().getName() );
 
		id.setName( "HiA" );
 
		d2 = (SecureDocument) s.load( SecureDocument.class, d2id );
		d2.setOwner( "max" );
 
		s.flush();
 
		s.clear();
 
		d = (Document) s.load( Document.class, did );
		assertEquals( did, d.getId() );
		assertEquals( "HiA", d.getName() ); 
		assertNotNull( d.getContent() ); 
		assertEquals( "/", d.getParent().getName() ); 
		assertNotNull( d.getCreated() ); 
		assertNotNull( d.getModified() ); 
 
		d2 = (SecureDocument) s.load( SecureDocument.class, d2id );
		assertEquals( d2id, d2.getId() );
		assertEquals( "Secret", d2.getName() );
		assertNotNull( d2.getContent() );
		assertEquals( "max", d2.getOwner() );
		assertEquals( "/", d2.getParent().getName() );
		// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint  
		// column (0 <= val < 128) 
		assertEquals( (byte) 127, d2.getPermissionBits() );
		assertNotNull( d2.getCreated() );
		assertNotNull( d2.getModified() );
 
		s.delete( d.getParent() );
		s.delete( d );
		s.delete( d2 );
 
		t.commit();
		s.close();
	} 
} 
 
Connect your IDE to all the code out there  Get Codota for Java