Package naming corrections and cleanup.

This commit is contained in:
Ilkka Seppala
2015-09-18 19:59:52 +03:00
parent 570a30099e
commit dd0fcea090
20 changed files with 33 additions and 284 deletions
@@ -0,0 +1,39 @@
package com.iluwatar.servicelayer.spell;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import com.iluwatar.servicelayer.common.DaoBaseImpl;
/**
*
* SpellDao implementation.
*
*/
public class SpellDaoImpl extends DaoBaseImpl<Spell> implements SpellDao {
@Override
public Spell findByName(String name) {
Session session = getSession();
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();
result.getSpellbook().getWizards().size();
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
session.close();
}
return result;
}
}