#507 SonarQube blocker severity bugs
This commit is contained in:
@ -27,6 +27,7 @@ import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
@ -45,13 +46,17 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
protected Class<E> persistentClass = (Class<E>) ((ParameterizedType) getClass()
|
||||
.getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
|
||||
protected Session getSession() {
|
||||
return HibernateUtil.getSessionFactory().openSession();
|
||||
/*
|
||||
* Making this getSessionFactory() instead of getSession() so that it is the responsibility
|
||||
* of the caller to open as well as close the session (prevents potential resource leak).
|
||||
*/
|
||||
protected SessionFactory getSessionFactory() {
|
||||
return HibernateUtil.getSessionFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E find(Long id) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
E result = null;
|
||||
try {
|
||||
@ -73,7 +78,7 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
|
||||
@Override
|
||||
public void persist(E entity) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
@ -91,7 +96,7 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
|
||||
@Override
|
||||
public E merge(E entity) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
E result = null;
|
||||
try {
|
||||
@ -111,7 +116,7 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
|
||||
@Override
|
||||
public void delete(E entity) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = session.beginTransaction();
|
||||
@ -129,7 +134,7 @@ public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
|
||||
@Override
|
||||
public List<E> findAll() {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
List<E> result = null;
|
||||
try {
|
||||
|
@ -38,7 +38,7 @@ public class SpellDaoImpl extends DaoBaseImpl<Spell> implements SpellDao {
|
||||
|
||||
@Override
|
||||
public Spell findByName(String name) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
Spell result = null;
|
||||
try {
|
||||
|
@ -38,7 +38,7 @@ public class SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements Spellboo
|
||||
|
||||
@Override
|
||||
public Spellbook findByName(String name) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
Spellbook result = null;
|
||||
try {
|
||||
|
@ -39,7 +39,7 @@ public class WizardDaoImpl extends DaoBaseImpl<Wizard> implements WizardDao {
|
||||
|
||||
@Override
|
||||
public Wizard findByName(String name) {
|
||||
Session session = getSession();
|
||||
Session session = getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
Wizard result = null;
|
||||
try {
|
||||
|
Reference in New Issue
Block a user