Code example for Session

Methods: closeflushsavebeginTransaction

0
 
	private void populateDatabase() { 
		Session session = openSession();
 
		try { 
			Transaction t = session.beginTransaction();
 
			ConcreteEntity entity = new ConcreteEntity();
			session.save( entity );
			entityId = entity.getId();
 
			LazyAbstractEntityReference reference = new LazyAbstractEntityReference( entity );
			session.save( reference );
			entityReferenceId = reference.getId();
 
			session.flush();
			t.commit();
		} 
		finally { 
			session.close();
		} 
	} 
 
	@SuppressWarnings("unchecked") 
	private static <T> List<T> doSearch(Session session, Class<T> clazz, Integer entityId) {
Experience pair programming with AI  Get Codota for Java