Class BaseDao
- java.lang.Object
-
- com.avoka.core.dao.BaseDao
-
- Direct Known Subclasses:
AbstractDao,ApplicationFormDao,ApplicationPackageDao,ApplicationServiceDao,ClientReconciliationFileDao,ClientRefDataDao,JobEventLogDao,JobPropertyDao,JobStepDao,OfflineSyncLogDao,PrefillParamXpathMapDao,ReleaseVersionDao,SubmissionDeliveryFuncDao,SubmissionMilestoneDao,SubmissionServiceDao,SubmissionServiceUsageDao,SystemHealthDao,TPacDao,UserGroupDao,UserRoleDao,WorkspaceDao
public abstract class BaseDao extends Object
Provides the base Data Access Object (DAO) for entity DAO classes to extend.DAO objects are responsible for create, read, update and delete (CRUD) operations on entity DataObject classes. DAO classes should not hold any state, and should be thread-safe.
Please Note: DAO classes are not responsible for committing or rolling back changes to the DataContext. This responsiblity lies with the calling code typically a service object or page object.
If a DataContext is not bound to the current thread this class will create and bind a DataContext to the thread. It is then up to the calling code to commit or rollback any changes to the data context.
This class provides protected utility methods which DAO entity classes can use for query, creating and deletion operations against the thread local data context. These methods have protected level access so they are not vissible to calling code which does not subclass BaseDao.
-
-
Field Summary
Fields Modifier and Type Field Description static intFETCH_LIMITThe default database fetch limit.static intSTATEMENT_MAX_NO_PARAMETERSThe maximum number of parameters that shall be used in a SQL query.
-
Constructor Summary
Constructors Constructor Description BaseDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddOrdering(org.apache.cayenne.query.SelectQuery query, String property)Deprecated.protected voidaddOrderingCaseInsensitive(org.apache.cayenne.query.SelectQuery query, String property)protected voidaddOrderingCaseSensitive(org.apache.cayenne.query.SelectQuery query, String property)protected voidandQueryBetween(org.apache.cayenne.query.SelectQuery query, String property, Date startDate, Date endDate)protected voidandQueryInExp(org.apache.cayenne.query.SelectQuery query, String property, Object[] values)protected voidandQueryInExp(org.apache.cayenne.query.SelectQuery query, String property, Collection<?> values)protected voidandQueryLikeIgnoreCaseExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected voidandQueryMatchDbExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected voidandQueryMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected voidandQueryMatchIsNotNull(org.apache.cayenne.query.SelectQuery query, String property)protected voidandQueryMatchIsNull(org.apache.cayenne.query.SelectQuery query, String property)protected voidandQueryNoMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected voidandQueryNotTrue(org.apache.cayenne.query.SelectQuery query, String property)protected voiddeleteObject(org.apache.cayenne.DataObject dataObject)protected voiddeleteObjects(Collection objects)protected org.apache.cayenne.DataObjectfindObject(Class dataObjectClass, String property, Object value)protected org.apache.cayenne.access.DataContextgetDataContext()intgetFetchLimit()Return the default query fetch limit.protected org.slf4j.LoggergetLogger()Return the service log.protected ObjectgetObjectForPK(Class dataObjectClass, Object id)protected <T> TnewObject(Class<T> persistentClass)protected voidorQueryLikeIgnoreCaseExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected voidorQueryMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)protected ListperformNamedQuery(String queryName, boolean refresh)protected ListperformNamedQuery(String queryName, String[] keys, String[] values, boolean refresh)protected ListperformNamedQuery(String queryName, Map parameters)protected ListperformNamedQuery(String queryName, Map parameters, boolean refresh)protected int[]performNonSelectingQuery(String queryName)protected int[]performNonSelectingQuery(String queryName, String[] keys, String[] values)protected int[]performNonSelectingQuery(String queryName, Map parameters)protected int[]performNonSelectingQuery(org.apache.cayenne.query.Query query)protected ListperformQuery(Class dataObjectClass, String property, Object value)protected ListperformQuery(org.apache.cayenne.query.SelectQuery query)Perform the given select query and set the default fetch limit, if no fetch limit has been set.protected ListperformQuery(org.apache.cayenne.query.SelectQuery query, int fetchLimit)protected voidregisterNewObject(org.apache.cayenne.DataObject dataObject)voidsetCacheStrategy(org.apache.cayenne.query.SelectQuery query, org.apache.cayenne.query.QueryCacheStrategy strategy, String cacheGroup)Set the application shared cache strategy and cache group on the given query.voidsetFetchLimit(int limit)Set the default query fetch limit.voidsetLocalCacheStrategy(org.apache.cayenne.query.SelectQuery query)Set the application local cache strategy and cache group on the given query.voidsetLocalCacheStrategy(org.apache.cayenne.query.SelectQuery query, String cacheGroup)Set the application local cache strategy and cache group on the given query.voidsetSharedCacheStrategy(org.apache.cayenne.query.SelectQuery query, String cacheGroup)Set the application shared cache strategy and cache group on the given query.protected MaptoMap(String[] keys, Object[] values)protected MaptoMap(String key, Object value)
-
-
-
Field Detail
-
FETCH_LIMIT
public static final int FETCH_LIMIT
The default database fetch limit.- See Also:
- Constant Field Values
-
STATEMENT_MAX_NO_PARAMETERS
public static final int STATEMENT_MAX_NO_PARAMETERS
The maximum number of parameters that shall be used in a SQL query. Limiting factors: Oracle, which can in theory take up to 64,000 parameters, can handle only up to 1000 values in a single IN clause. SQL server which only up to 2100 query parameters.- See Also:
- Constant Field Values
-
-
Method Detail
-
getFetchLimit
public int getFetchLimit()
Return the default query fetch limit.- Returns:
- the default query fetch limit
-
setFetchLimit
public void setFetchLimit(int limit)
Set the default query fetch limit.- Parameters:
limit- the default query fetch limit
-
setLocalCacheStrategy
public void setLocalCacheStrategy(org.apache.cayenne.query.SelectQuery query)
Set the application local cache strategy and cache group on the given query.- Parameters:
query- apply local cache strategy to the query
-
setLocalCacheStrategy
public void setLocalCacheStrategy(org.apache.cayenne.query.SelectQuery query, String cacheGroup)Set the application local cache strategy and cache group on the given query.- Parameters:
query- apply local cache strategy to the querycacheGroup- the cacheGroup for the query
-
setSharedCacheStrategy
public void setSharedCacheStrategy(org.apache.cayenne.query.SelectQuery query, String cacheGroup)Set the application shared cache strategy and cache group on the given query.- Parameters:
query- apply shared cache strategy to the querycacheGroup- the cacheGroup for the query
-
setCacheStrategy
public void setCacheStrategy(org.apache.cayenne.query.SelectQuery query, org.apache.cayenne.query.QueryCacheStrategy strategy, String cacheGroup)Set the application shared cache strategy and cache group on the given query.- Parameters:
query- apply strategy and associate cacheGroup to the querystrategy- the strategy for the querycacheGroup- the cacheGroup for the query
-
getLogger
protected org.slf4j.Logger getLogger()
Return the service log.- Returns:
- the service log
-
getDataContext
protected org.apache.cayenne.access.DataContext getDataContext()
-
registerNewObject
protected void registerNewObject(org.apache.cayenne.DataObject dataObject)
-
newObject
protected <T> T newObject(Class<T> persistentClass)
-
deleteObject
protected void deleteObject(org.apache.cayenne.DataObject dataObject)
-
deleteObjects
protected void deleteObjects(Collection objects)
-
findObject
protected org.apache.cayenne.DataObject findObject(Class dataObjectClass, String property, Object value)
-
performNonSelectingQuery
protected int[] performNonSelectingQuery(org.apache.cayenne.query.Query query)
-
performNonSelectingQuery
protected int[] performNonSelectingQuery(String queryName)
-
performNonSelectingQuery
protected int[] performNonSelectingQuery(String queryName, Map parameters)
-
performQuery
protected List performQuery(org.apache.cayenne.query.SelectQuery query)
Perform the given select query and set the default fetch limit, if no fetch limit has been set.
-
performQuery
protected List performQuery(org.apache.cayenne.query.SelectQuery query, int fetchLimit)
-
performNamedQuery
protected List performNamedQuery(String queryName, Map parameters, boolean refresh)
-
performNamedQuery
protected List performNamedQuery(String queryName, String[] keys, String[] values, boolean refresh)
-
performNonSelectingQuery
protected int[] performNonSelectingQuery(String queryName, String[] keys, String[] values)
-
andQueryMatchExp
protected void andQueryMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
andQueryMatchIsNotNull
protected void andQueryMatchIsNotNull(org.apache.cayenne.query.SelectQuery query, String property)
-
andQueryMatchIsNull
protected void andQueryMatchIsNull(org.apache.cayenne.query.SelectQuery query, String property)
-
andQueryInExp
protected void andQueryInExp(org.apache.cayenne.query.SelectQuery query, String property, Collection<?> values)
-
andQueryInExp
protected void andQueryInExp(org.apache.cayenne.query.SelectQuery query, String property, Object[] values)
-
andQueryNoMatchExp
protected void andQueryNoMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
andQueryMatchDbExp
protected void andQueryMatchDbExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
andQueryLikeIgnoreCaseExp
protected void andQueryLikeIgnoreCaseExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
andQueryBetween
protected void andQueryBetween(org.apache.cayenne.query.SelectQuery query, String property, Date startDate, Date endDate)
-
orQueryMatchExp
protected void orQueryMatchExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
orQueryLikeIgnoreCaseExp
protected void orQueryLikeIgnoreCaseExp(org.apache.cayenne.query.SelectQuery query, String property, Object value)
-
andQueryNotTrue
protected void andQueryNotTrue(org.apache.cayenne.query.SelectQuery query, String property)
-
addOrdering
@Deprecated protected void addOrdering(org.apache.cayenne.query.SelectQuery query, String property)
Deprecated.
-
addOrderingCaseSensitive
protected void addOrderingCaseSensitive(org.apache.cayenne.query.SelectQuery query, String property)
-
addOrderingCaseInsensitive
protected void addOrderingCaseInsensitive(org.apache.cayenne.query.SelectQuery query, String property)
-
-