Code example for Session

Methods: closesavebeginTransaction

0
	} 
 
	private void prepareEntities(String level3Name) {
		Session session = openSession();
		try { 
			Transaction transaction = session.beginTransaction();
 
			Level1 level1 = new Level1();
			DerivedLevel2 level2 = new DerivedLevel2();
			Level3 level3 = new Level3();
 
			level1.setLevel2Child( level2 );
			level2.setLevel1Parent( level1 );
			level2.setLevel3Child( level3 );
			level3.setLevel2Parent( level2 );
 
			level3.setName( level3Name );
 
			session.save( level1 );
			session.save( level2 );
			session.save( level3 );
 
			transaction.commit();
		} 
		finally { 
			session.close();
		} 
	} 
 
	private void changeLevel3Name(String currentName, String newName) {
		FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
Experience pair programming with AI  Get Codota for Java