Package com.ocs.dynamo.dao.impl
Class BaseDaoImpl<ID,T extends AbstractEntity<ID>>
- java.lang.Object
-
- com.ocs.dynamo.dao.impl.BaseDaoImpl<ID,T>
-
- Type Parameters:
ID- type parameter, the type of the primary key of the domain objectT- type parameter, the domain object class
- All Implemented Interfaces:
BaseDao<ID,T>
- Direct Known Subclasses:
DefaultDaoImpl,TreeDaoImpl
public abstract class BaseDaoImpl<ID,T extends AbstractEntity<ID>> extends Object implements BaseDao<ID,T>
Base class for all DAO implementations- Author:
- bas.rutten
-
-
Constructor Summary
Constructors Constructor Description BaseDaoImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddParameter(javax.persistence.Query query, String name, Object value)Adds a parameter to a query but only if the provided value is not nulllongcount()longcount(Filter filter, boolean distinct)protected com.querydsl.jpa.impl.JPADeleteClausecreateDeleteClause()Creates a new new JPADeleteClause for the entityprotected com.querydsl.jpa.impl.JPAQuery<T>createQuery()Creates a default query that simply retrieves instances of the domain classprotected com.querydsl.jpa.impl.JPAUpdateClausecreateUpdateClause()Creates a new new JPAUpdateClause for the entityvoiddelete(List<T> list)voiddelete(T t)List<T>fetch(Filter filter, FetchJoinInformation... joins)List<T>fetch(Filter filter, Pageable pageable, FetchJoinInformation... joins)List<T>fetch(Filter filter, SortOrders sortOrders, FetchJoinInformation... joins)TfetchById(ID id, FetchJoinInformation... joins)List<T>fetchByIds(List<ID> ids, SortOrders sortOrders, FetchJoinInformation... joins)List<T>fetchByIds(List<ID> ids, Filter additionalFilter, SortOrders sortOrders, FetchJoinInformation... joins)TfetchByUniqueProperty(String propertyName, Object value, boolean caseSensitive, FetchJoinInformation... joins)List<T>find(Filter filter)List<T>find(Filter filter, SortOrder... orders)List<T>findAll()List<T>findAll(SortOrder... sortOrders)TfindById(ID id)TfindByUniqueProperty(String propertyName, Object value, boolean caseSensitive)<S> List<S>findDistinct(Filter filter, String distinctField, Class<S> elementType, SortOrder... orders)<S> List<S>findDistinctInCollectionTable(String tableName, String distinctField, Class<S> elementType)List<ID>findIds(Filter filter, SortOrder... sortOrders)List<ID>findIds(Filter filter, Integer maxResults, SortOrder... sortOrders)List<?>findSelect(Filter filter, String[] selectProperties, Pageable pageable)List<?>findSelect(Filter filter, String[] selectProperties, SortOrders orders)voidflushAndClear()protected abstract com.querydsl.core.types.dsl.EntityPathBase<T>getDslRoot()Returns the query DSL rootprotected javax.persistence.EntityManagergetEntityManager()protected FetchJoinInformation[]getFetchJoins()Returns the fetch joins that must be included in a query to fetch the IDs.protected TgetFirstValue(List<T> list)Returns the first value of a listprotected Optional<T>getFirstValueOptional(List<T> list)Returns an optional containing the first value of the provided listList<T>save(List<T> list)Tsave(T t)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ocs.dynamo.dao.BaseDao
getEntityClass
-
-
-
-
Method Detail
-
addParameter
protected void addParameter(javax.persistence.Query query, String name, Object value)Adds a parameter to a query but only if the provided value is not null- Parameters:
query- the query to add the parameter toname- the name of the parametervalue- the value of the parameter
-
count
public long count()
-
count
public long count(Filter filter, boolean distinct)
-
createDeleteClause
protected com.querydsl.jpa.impl.JPADeleteClause createDeleteClause()
Creates a new new JPADeleteClause for the entity- Returns:
-
createQuery
protected com.querydsl.jpa.impl.JPAQuery<T> createQuery()
Creates a default query that simply retrieves instances of the domain class- Returns:
-
createUpdateClause
protected com.querydsl.jpa.impl.JPAUpdateClause createUpdateClause()
Creates a new new JPAUpdateClause for the entity- Returns:
-
delete
public void delete(T t)
-
fetch
public List<T> fetch(Filter filter, FetchJoinInformation... joins)
-
fetch
public List<T> fetch(Filter filter, Pageable pageable, FetchJoinInformation... joins)
-
fetch
public List<T> fetch(Filter filter, SortOrders sortOrders, FetchJoinInformation... joins)
-
fetchById
public T fetchById(ID id, FetchJoinInformation... joins)
-
fetchByIds
public List<T> fetchByIds(List<ID> ids, SortOrders sortOrders, FetchJoinInformation... joins)
- Specified by:
fetchByIdsin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
fetchByIds
public List<T> fetchByIds(List<ID> ids, Filter additionalFilter, SortOrders sortOrders, FetchJoinInformation... joins)
- Specified by:
fetchByIdsin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
fetchByUniqueProperty
public T fetchByUniqueProperty(String propertyName, Object value, boolean caseSensitive, FetchJoinInformation... joins)
- Specified by:
fetchByUniquePropertyin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
findSelect
public List<?> findSelect(Filter filter, String[] selectProperties, SortOrders orders)
- Specified by:
findSelectin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
findSelect
public List<?> findSelect(Filter filter, String[] selectProperties, Pageable pageable)
- Specified by:
findSelectin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
findByUniqueProperty
public T findByUniqueProperty(String propertyName, Object value, boolean caseSensitive)
- Specified by:
findByUniquePropertyin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
findDistinct
public <S> List<S> findDistinct(Filter filter, String distinctField, Class<S> elementType, SortOrder... orders)
- Specified by:
findDistinctin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
findDistinctInCollectionTable
public <S> List<S> findDistinctInCollectionTable(String tableName, String distinctField, Class<S> elementType)
- Specified by:
findDistinctInCollectionTablein interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
flushAndClear
public void flushAndClear()
- Specified by:
flushAndClearin interfaceBaseDao<ID,T extends AbstractEntity<ID>>
-
getDslRoot
protected abstract com.querydsl.core.types.dsl.EntityPathBase<T> getDslRoot()
Returns the query DSL root- Returns:
-
getEntityManager
protected javax.persistence.EntityManager getEntityManager()
-
getFetchJoins
protected FetchJoinInformation[] getFetchJoins()
Returns the fetch joins that must be included in a query to fetch the IDs. This method return an empty array by default - override when needed- Returns:
-
getFirstValue
protected T getFirstValue(List<T> list)
Returns the first value of a list- Parameters:
list- the list- Returns:
- the first value of the list, or
nullif this does not exist
-
getFirstValueOptional
protected Optional<T> getFirstValueOptional(List<T> list)
Returns an optional containing the first value of the provided list- Parameters:
list-- Returns:
-
-