Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations.
This commit is contained in:
@ -47,6 +47,9 @@ public class App {
|
||||
queryData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize data
|
||||
*/
|
||||
public static void initData() {
|
||||
// spells
|
||||
Spell spell1 = new Spell("Ice dart");
|
||||
@ -149,6 +152,9 @@ public class App {
|
||||
wizardDao.merge(wizard4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the data
|
||||
*/
|
||||
public static void queryData() {
|
||||
MagicService service =
|
||||
new MagicServiceImpl(new WizardDaoImpl(), new SpellbookDaoImpl(), new SpellDaoImpl());
|
||||
|
@ -39,8 +39,9 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
result = (E) criteria.uniqueResult();
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
@ -57,8 +58,9 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
session.persist(entity);
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
@ -75,8 +77,9 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
result = (E) session.merge(entity);
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
@ -93,8 +96,9 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
session.delete(entity);
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
@ -111,8 +115,9 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
Criteria criteria = session.createCriteria(persistentClass);
|
||||
result = criteria.list();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
|
@ -14,11 +14,11 @@ import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
*/
|
||||
public class HibernateUtil {
|
||||
|
||||
private static final SessionFactory sessionFactory;
|
||||
private static final SessionFactory SESSION_FACTORY;
|
||||
|
||||
static {
|
||||
try {
|
||||
sessionFactory =
|
||||
SESSION_FACTORY =
|
||||
new Configuration().addAnnotatedClass(Wizard.class).addAnnotatedClass(Spellbook.class)
|
||||
.addAnnotatedClass(Spell.class)
|
||||
.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect")
|
||||
@ -33,6 +33,6 @@ public class HibernateUtil {
|
||||
}
|
||||
|
||||
public static SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
return SESSION_FACTORY;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ public class MagicServiceImpl implements MagicService {
|
||||
private SpellbookDao spellbookDao;
|
||||
private SpellDao spellDao;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public MagicServiceImpl(WizardDao wizardDao, SpellbookDao spellbookDao, SpellDao spellDao) {
|
||||
this.wizardDao = wizardDao;
|
||||
this.spellbookDao = spellbookDao;
|
||||
|
@ -27,8 +27,9 @@ public class SpellDaoImpl extends DaoBaseImpl<Spell> implements SpellDao {
|
||||
result.getSpellbook().getWizards().size();
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
|
@ -28,8 +28,9 @@ public class SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements Spellboo
|
||||
result.getWizards().size();
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
|
@ -30,8 +30,9 @@ public class WizardDaoImpl extends DaoBaseImpl<Wizard> implements WizardDao {
|
||||
}
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
if (tx != null)
|
||||
if (tx != null) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
session.close();
|
||||
|
Reference in New Issue
Block a user