net.dontdrinkandroot.persistence.dao

## Class TypedJpaDao<E extends Entity<I>,I>

- java.lang.Object
- - net.dontdrinkandroot.persistence.dao.GenericJpaDao
  - - net.dontdrinkandroot.persistence.dao.TypedJpaDao<E,I>

Type Parameters:
  `E` - Type of the `Entity`.
  `I` - Type of the `Entity`'s id.

All Implemented Interfaces:
  GenericDao, TypedDao<E,I>

    public class TypedJpaDao<E extends Entity<I>,I>
    extends GenericJpaDao
    implements TypedDao<E,I>

Base implementation of a `TypedDao` that uses a JPA `EntityManager`.

Author:
  Philip W. Sorst <philip@sorst.net>

### Field Summary

Fields
`protected Class<E>` `entityClass`

### Constructor Summary

Constructors
Constructor and Description
`TypedJpaDao(Class<E> entityClass)`

### Method Summary

Methods
`void` `delete(E entity)` Deletes the given Entity.
`void` `delete(I id)` Deletes the entity with the given id.
`E` `find(I id)` Finds the entity with the given id.
`List<E>` `findAll()` Finds all entities.
`List<E>` `findAll(Collection<PredicateBuilder<E>> filters)` Finds all entities that match all predicates generated by the given `PredicateBuilder` s.
`List<E>` `findAll(PredicateBuilder<E>... filters)` Finds all entities that match all predicates generated by the given `PredicateBuilder` s.
`List<E>` `findAll(PredicateBuilder<E> filter)` Finds all entities that match all predicates generated by the given `PredicateBuilder` s.
`List<E>` `findAll(javax.persistence.metamodel.SingularAttribute<? super E,?> attribute, boolean asc)` Finds all entities ordered by the given attribute and the given sort order.
`List<E>` `findAll(javax.persistence.metamodel.SingularAttribute<? super E,?> attribute, boolean asc, int firstResult, int maxResults)` Finds all entities ordered by the given attribute and the given sort order with the result set limit to the given size.
`long` `getCount()` Get the total number of entities in this Dao.
`E` `load(I id)` Loads the entity with the given id or throws an Exception if it was not found.

### Methods inherited from class net.dontdrinkandroot.persistence.dao.GenericJpaDao

`delete, delete, find, find, find, find, findAll, findFirstOrNull, findSingle, findSingleOrNull, getCount, getCriteriaBuilder, getEntityManager, getLogger, load, save, setEntityManager, setLogger`

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

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

### Methods inherited from interface net.dontdrinkandroot.persistence.dao.GenericDao

`delete, delete, find, findAll, getCount, load, save`

### Field Detail

#### entityClass

    protected Class<E extends Entity<I>> entityClass

### Constructor Detail

#### TypedJpaDao

    public TypedJpaDao(Class<E> entityClass)

### Method Detail

#### delete

    @Transactional(propagation=MANDATORY)
    public void delete(E entity)

Description copied from interface: `TypedDao`
Deletes the given Entity.

Specified by:
  `delete` in interface `TypedDao<E extends Entity<I>,I>`

#### delete

    @Transactional(propagation=MANDATORY)
    public void delete(I id)

Description copied from interface: `TypedDao`
Deletes the entity with the given id.

Specified by:
  `delete` in interface `TypedDao<E extends Entity<I>,I>`

#### find

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public E find(I id)

Description copied from interface: `TypedDao`
Finds the entity with the given id.

Specified by:
  `find` in interface `TypedDao<E extends Entity<I>,I>`

#### getCount

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public long getCount()

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

Specified by:
  `getCount` in interface `TypedDao<E extends Entity<I>,I>`

#### load

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public E load(I id)

Description copied from interface: `TypedDao`
Loads the entity with the given id or throws an Exception if it was not found.

Specified by:
  `load` in interface `TypedDao<E extends Entity<I>,I>`

#### findAll

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public List<E> findAll()

Description copied from interface: `TypedDao`
Finds all entities.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`

#### findAll

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

Description copied from interface: `TypedDao`
Finds all entities ordered by the given attribute and the given sort order.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`
  `asc` - True to sort in ascending order, false to sort in descending order.

#### findAll

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

Description copied from interface: `TypedDao`
Finds all entities ordered by the given attribute and the given sort order with the result set limit to the given size.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`
  `asc` - True to sort in ascending order, false to sort in descending order.
  `firstResult` - Position of the first result to retrieve.

#### findAll

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public List<E> findAll(PredicateBuilder<E> filter)

Description copied from interface: `TypedDao`
Finds all entities that match all predicates generated by the given `PredicateBuilder` s.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`

#### findAll

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public List<E> findAll(Collection<PredicateBuilder<E>> filters)

Description copied from interface: `TypedDao`
Finds all entities that match all predicates generated by the given `PredicateBuilder` s.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`

#### findAll

    @Transactional(propagation=MANDATORY,
                   readOnly=true)
    public List<E> findAll(PredicateBuilder<E>... filters)

Description copied from interface: `TypedDao`
Finds all entities that match all predicates generated by the given `PredicateBuilder` s.

Specified by:
  `findAll` in interface `TypedDao<E extends Entity<I>,I>`