@Test public void testFindByName() throws Exception { final SpellbookDaoImpl dao = getDao(); final List<Spellbook> allBooks = dao.findAll(); for (final Spellbook book : allBooks) { final Spellbook spellByName = dao.findByName(book.getName()); assertNotNull(spellByName); assertEquals(book.getId(), spellByName.getId()); assertEquals(book.getName(), spellByName.getName()); } }
@Override public Spellbook findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Spellbook result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Spellbook) criteria.uniqueResult(); result.getSpells().size(); result.getWizards().size(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; }
SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements SpellbookDao { @Override public Spellbook findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Spellbook result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Spellbook) criteria.uniqueResult(); result.getSpells().size(); result.getWizards().size(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; } }
SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements SpellbookDao { @Override public Spellbook findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Spellbook result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Spellbook) criteria.uniqueResult(); result.getSpells().size(); result.getWizards().size(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; }  }
SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements SpellbookDao { @Override public Spellbook findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Spellbook result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Spellbook) criteria.uniqueResult(); result.getSpells().size(); result.getWizards().size(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; }  @Override Spellbook findByName(String name); }
SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements SpellbookDao { @Override public Spellbook findByName(String name) { Session session = getSessionFactory().openSession(); Transaction tx = null; Spellbook result = null; try { tx = session.beginTransaction(); Criteria criteria = session.createCriteria(persistentClass); criteria.add(Restrictions.eq("name", name)); result = (Spellbook) criteria.uniqueResult(); result.getSpells().size(); result.getWizards().size(); tx.commit(); } catch (Exception e) { if (tx != null) { tx.rollback(); } throw e; } finally { session.close(); } return result; }  @Override Spellbook findByName(String name);  }