Rename class
This commit is contained in:
parent
fb1c033a34
commit
7264e610d0
@ -7,22 +7,22 @@ import java.util.List;
|
|||||||
|
|
||||||
public class GenericDAO<T> implements dst.ass1.jpa.dao.GenericDAO<T> {
|
public class GenericDAO<T> implements dst.ass1.jpa.dao.GenericDAO<T> {
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final Class aClass;
|
private final Class type;
|
||||||
|
|
||||||
public GenericDAO(EntityManager entityManager, Class aClass) {
|
public GenericDAO(EntityManager entityManager, Class type) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.aClass = aClass;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T findById(Long id) {
|
public T findById(Long id) {
|
||||||
return (T) entityManager.find(aClass, id);
|
return (T) entityManager.find(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<T> findAll() {
|
public List<T> findAll() {
|
||||||
CriteriaQuery<T> criteriaQuery = entityManager.getCriteriaBuilder().createQuery(aClass);
|
CriteriaQuery<T> criteriaQuery = entityManager.getCriteriaBuilder().createQuery(type);
|
||||||
Root<T> root = criteriaQuery.from(aClass);
|
Root<T> root = criteriaQuery.from(type);
|
||||||
criteriaQuery.select(root);
|
criteriaQuery.select(root);
|
||||||
|
|
||||||
return entityManager.createQuery(criteriaQuery).getResultList();
|
return entityManager.createQuery(criteriaQuery).getResultList();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user