Code example for SessionFactory

Methods: close

0
	} 
 
	@Override 
	protected void tearDown() throws Exception {
		if ( sessionFactory != null ) {
			sessionFactory.close();
		} 
	} 
 
	public void testBasicUsage() { 
		// create a couple of events... 
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		session.save( new Event( "Our very first event!", new Date() ) );
		session.save( new Event( "A follow up event", new Date() ) );
		session.getTransaction().commit();
		session.close();
 
		// now lets pull events from the database and list them 
		session = sessionFactory.openSession();
Experience pair programming with AI  Get Codota for Java