mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-04-08 03:44:31 +00:00
Additional refactor
This commit is contained in:
parent
43038310b4
commit
d4b0a87228
@ -461,7 +461,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
}
|
||||
|
||||
Transaction tx = null;
|
||||
Session session = factory.getCurrentSession();
|
||||
Session session = getSession();
|
||||
try {
|
||||
LOGGER.debug("retrieving " + clazz.toString() + " from db");
|
||||
tx = session.beginTransaction();
|
||||
@ -509,7 +509,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
return null;
|
||||
}
|
||||
Transaction tx = null;
|
||||
Session session = factory.getCurrentSession();
|
||||
Session session =getSession();
|
||||
try {
|
||||
LOGGER.debug("retrieving object from db");
|
||||
tx = session.beginTransaction();
|
||||
@ -554,7 +554,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
Class<T> searchClass = entity;
|
||||
List<T> objects = new ArrayList<>();
|
||||
Transaction tx = null;
|
||||
Session session = factory.getCurrentSession();
|
||||
Session session = getSession();
|
||||
try {
|
||||
LOGGER.debug("Retrieving objects from db of class {}", searchClass);
|
||||
tx = session.beginTransaction();
|
||||
@ -632,7 +632,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
|
||||
List<T> objects = new ArrayList<>();
|
||||
Transaction tx = null;
|
||||
Session session = factory.getCurrentSession();
|
||||
Session session = getSession();
|
||||
CriteriaBuilder builder = session.getCriteriaBuilder();
|
||||
// try {
|
||||
LOGGER.debug("updating object in db");
|
||||
|
@ -3,9 +3,9 @@ package hirs.attestationca.persist;
|
||||
import hirs.persist.RepositoryManager;
|
||||
import hirs.repository.RepoPackage;
|
||||
import hirs.repository.Repository;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ -22,12 +22,12 @@ public class DBRepositoryManager implements RepositoryManager {
|
||||
* Creates a new <code>DBRepositoryManager</code> that uses the default
|
||||
* database. The default database is used to store and retrieve all objects.
|
||||
*
|
||||
* @param sessionFactory session factory used to access database connections
|
||||
* @param entityManager object used to access database connections
|
||||
*/
|
||||
public DBRepositoryManager(final SessionFactory sessionFactory) {
|
||||
public DBRepositoryManager(final EntityManager entityManager) {
|
||||
super();
|
||||
repositoryDBManager = new DBManager<>(Repository.class, sessionFactory);
|
||||
repoPackageDBManager = new DBManager<>(RepoPackage.class, sessionFactory);
|
||||
repositoryDBManager = new DBManager<>(Repository.class, entityManager);
|
||||
repoPackageDBManager = new DBManager<>(RepoPackage.class, entityManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user