net.dontdrinkandroot.persistence.dao

## Class AbstractJpaDao<T extends Entity<K>,K>

- java.lang.Object
- - net.dontdrinkandroot.persistence.dao.AbstractJpaDao<T,K>

All Implemented Interfaces:
  Dao<T,K>

    public class AbstractJpaDao<T extends Entity<K>,K>
    extends Object
    implements Dao<T,K>

### Field Summary

Fields
`protected Class<T>` `entityClass`
`protected org.slf4j.Logger` `logger`

### Constructor Summary

Constructors
Constructor and Description
`AbstractJpaDao(Class<T> entityClass)`

### Method Summary

Methods
`protected Iterator<T>` `createIterator(javax.persistence.TypedQuery<T> query, int pageSize)`
`void` `delete(K id)`
`void` `delete(T entity)`
`protected <V> List<V>` `find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)`
`protected <V> List<V>` `find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery, int maxResults)`
`protected <V> List<V>` `find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery, int firstResult, int maxResults)`
`T` `find(K id)`
`List<T>` `findAll()`
`List<T>` `findAll(AbstractFilter<T>... filters)`
`List<T>` `findAll(AbstractFilter<T> filter)`
`List<T>` `findAll(Collection<AbstractFilter<T>> filters)`
`List<T>` `findAll(javax.persistence.metamodel.SingularAttribute<? super T,?> attribute, boolean asc)`
`<V> T` `findByAttribute(javax.persistence.metamodel.SingularAttribute<? super T,V> attribute, V value)`
`protected <V> V` `findSingle(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)`
`protected <V> V` `findSingleOrNull(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)`
`List<T>` `findSorted(javax.persistence.metamodel.SingularAttribute<? super T,?> attribute, boolean asc, int firstResult, int maxResults)`
`long` `getCount()` Get the total number of entities in this Dao.
`protected javax.persistence.criteria.CriteriaBuilder` `getCriteriaBuilder()`
`javax.persistence.EntityManager` `getEntityManager()`
`T` `load(K id)`
`T` `save(T entity)`
`void` `setEntityManager(javax.persistence.EntityManager entityManager)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### entityClass

    protected Class<T extends Entity<K>> entityClass

#### logger

    protected final org.slf4j.Logger logger

### Constructor Detail

#### AbstractJpaDao

    public AbstractJpaDao(Class<T> entityClass)

### Method Detail

#### setEntityManager

    public void setEntityManager(javax.persistence.EntityManager entityManager)

#### getEntityManager

    public javax.persistence.EntityManager getEntityManager()

#### delete

    @Transactional
    public void delete(T entity)

Specified by:
  `delete` in interface `Dao<T extends Entity<K>,K>`

#### delete

    @Transactional
    public void delete(K id)

Specified by:
  `delete` in interface `Dao<T extends Entity<K>,K>`

#### find

    @Transactional(readOnly=true)
    public T find(K id)

Specified by:
  `find` in interface `Dao<T extends Entity<K>,K>`

#### getCount

    @Transactional(readOnly=true)
    public long getCount()

Description copied from interface: `Dao`
Get the total number of entities in this Dao.

Specified by:
  `getCount` in interface `Dao<T extends Entity<K>,K>`

#### findByAttribute

    @Transactional(readOnly=true)
    public <V> T findByAttribute(javax.persistence.metamodel.SingularAttribute<? super T,V> attribute,
                                      V value)

Specified by:
  `findByAttribute` in interface `Dao<T extends Entity<K>,K>`

#### load

    @Transactional(readOnly=true)
    public T load(K id)

Specified by:
  `load` in interface `Dao<T extends Entity<K>,K>`

#### save

    @Transactional
    public T save(T entity)

Specified by:
  `save` in interface `Dao<T extends Entity<K>,K>`

#### findAll

    @Transactional(readOnly=true)
    public List<T> findAll()

Specified by:
  `findAll` in interface `Dao<T extends Entity<K>,K>`

#### findAll

    @Transactional(readOnly=true)
    public List<T> findAll(javax.persistence.metamodel.SingularAttribute<? super T,?> attribute,
                                boolean asc)

Specified by:
  `findAll` in interface `Dao<T extends Entity<K>,K>`

#### findSorted

    @Transactional(readOnly=true)
    public List<T> findSorted(javax.persistence.metamodel.SingularAttribute<? super T,?> attribute,
                                   boolean asc,
                                   int firstResult,
                                   int maxResults)

Specified by:
  `findSorted` in interface `Dao<T extends Entity<K>,K>`

#### findAll

    @Transactional(readOnly=true)
    public List<T> findAll(AbstractFilter<T> filter)

Specified by:
  `findAll` in interface `Dao<T extends Entity<K>,K>`

#### findAll

    @Transactional(readOnly=true)
    public List<T> findAll(Collection<AbstractFilter<T>> filters)

Specified by:
  `findAll` in interface `Dao<T extends Entity<K>,K>`

#### findAll

    @Transactional(readOnly=true)
    public List<T> findAll(AbstractFilter<T>... filters)

Specified by:
  `findAll` in interface `Dao<T extends Entity<K>,K>`

#### find

    protected <V> List<V> find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)

#### find

    protected <V> List<V> find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery,
                   int firstResult,
                   int maxResults)

#### find

    protected <V> List<V> find(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery,
                   int maxResults)

#### findSingle

    protected <V> V findSingle(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)

#### findSingleOrNull

    protected <V> V findSingleOrNull(javax.persistence.criteria.CriteriaQuery<V> criteriaQuery)

#### getCriteriaBuilder

    protected javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()

#### createIterator

    protected Iterator<T> createIterator(javax.persistence.TypedQuery<T> query,
                             int pageSize)