fr.paris.lutece.plugins.userban.dao
Class AbstractDAO<K,E>

java.lang.Object
  extended by fr.paris.lutece.util.jpa.JPAGenericDAO<K,E>
      extended by fr.paris.lutece.portal.service.jpa.JPALuteceDAO<K,E>
          extended by fr.paris.lutece.plugins.userban.dao.AbstractDAO<K,E>
Type Parameters:
K - the class for entity Key
E - the entity class
All Implemented Interfaces:
IAbstractDAO<K,E>, fr.paris.lutece.util.jpa.IGenericDAO<K,E>
Direct Known Subclasses:
UserDAO

public abstract class AbstractDAO<K,E>
extends fr.paris.lutece.portal.service.jpa.JPALuteceDAO<K,E>
implements IAbstractDAO<K,E>

The abstract class for all DAO


Field Summary
static String LIKE_ENCLOSING
           
static org.apache.log4j.Logger LOGGER
           
 
Constructor Summary
AbstractDAO()
           
 
Method Summary
protected  void addRestriction(javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.Expression<Boolean> exp)
          Add a predicate to an existing query
static String buildCriteriaLikeString(String strToEnclose)
          Encloses string with percent "%"
protected  void buildCriteriaQuery(AbstractFilter<K> filter, javax.persistence.criteria.Root<E> root, javax.persistence.criteria.CriteriaQuery<E> query, javax.persistence.criteria.CriteriaBuilder builder)
          the method to implement to add the constraint
protected  void buildSortQuery(AbstractFilter<K> filter, javax.persistence.criteria.Root<E> root, javax.persistence.criteria.CriteriaQuery<E> query, javax.persistence.criteria.CriteriaBuilder builder)
          Add the order by parameter to the query.
protected
<T> PagedQuery<E>
createPagedQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery, PaginationProperties paginationProperties)
          Generate count query from criteria query and return a paged query.
 ResultList<E> find(AbstractFilter<K> filter, Class<E> type, PaginationProperties paginationProperties)
          Find the bean which correspond to the filter given
 ResultList<E> findAll(PaginationProperties paginationProperties)
          Return all entities paged.
 
Methods inherited from class fr.paris.lutece.portal.service.jpa.JPALuteceDAO
createNativeQuery, getEntityManagerFactory, getPluginName
 
Methods inherited from class fr.paris.lutece.util.jpa.JPAGenericDAO
create, detach, findAll, findById, flush, getEM, getEntityClass, getEntityClassName, remove, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.paris.lutece.util.jpa.IGenericDAO
create, detach, findAll, findById, flush, remove, update
 

Field Detail

LOGGER

public static final org.apache.log4j.Logger LOGGER

LIKE_ENCLOSING

public static final String LIKE_ENCLOSING
See Also:
Constant Field Values
Constructor Detail

AbstractDAO

public AbstractDAO()
Method Detail

buildCriteriaQuery

protected void buildCriteriaQuery(AbstractFilter<K> filter,
                                  javax.persistence.criteria.Root<E> root,
                                  javax.persistence.criteria.CriteriaQuery<E> query,
                                  javax.persistence.criteria.CriteriaBuilder builder)
the method to implement to add the constraint

Parameters:
filter - the bean filter
root - the table root
query - the criteria query
builder - the criteria builder

createPagedQuery

protected <T> PagedQuery<E> createPagedQuery(javax.persistence.criteria.CriteriaQuery<T> criteriaQuery,
                                             PaginationProperties paginationProperties)
Generate count query from criteria query and return a paged query.

Type Parameters:
T - the generic type of criteria query
Parameters:
criteriaQuery - criteria query
paginationProperties - pagination data
Returns:
query paged

findAll

public ResultList<E> findAll(PaginationProperties paginationProperties)
Return all entities paged.

Specified by:
findAll in interface IAbstractDAO<K,E>
Parameters:
paginationProperties - properties for pagination
Returns:
the result list

addRestriction

protected void addRestriction(javax.persistence.criteria.CriteriaQuery<?> query,
                              javax.persistence.criteria.Expression<Boolean> exp)
Add a predicate to an existing query

Parameters:
query - existing query
exp - restriction

buildSortQuery

protected void buildSortQuery(AbstractFilter<K> filter,
                              javax.persistence.criteria.Root<E> root,
                              javax.persistence.criteria.CriteriaQuery<E> query,
                              javax.persistence.criteria.CriteriaBuilder builder)
Add the order by parameter to the query.

Parameters:
filter - the filter
root - the offer root
query - the criteria query
builder - the criteria builder

find

public ResultList<E> find(AbstractFilter<K> filter,
                          Class<E> type,
                          PaginationProperties paginationProperties)
Description copied from interface: IAbstractDAO
Find the bean which correspond to the filter given

Specified by:
find in interface IAbstractDAO<K,E>
Parameters:
filter - the filter to use
type - the type class of the bean
paginationProperties - the pagination properties
Returns:
List of entities found.

buildCriteriaLikeString

public static String buildCriteriaLikeString(String strToEnclose)
Encloses string with percent "%"

Parameters:
strToEnclose - string to enclose
Returns:
"%" + strToEnclose + "%"


Copyright © 2013 Mairie de Paris. All Rights Reserved.