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