Class BaseDao
- Direct Known Subclasses:
AbstractDao
,ApplicationFormDao
,ApplicationPackageDao
,ApplicationServiceDao
,ClientReconciliationFileDao
,ClientRefDataDao
,JobEventLogDao
,JobPropertyDao
,JobStepDao
,PrefillParamXpathMapDao
,ReleaseVersionDao
,SubmissionDeliveryFuncDao
,SubmissionMilestoneDao
,SubmissionServiceDao
,SubmissionServiceUsageDao
,SystemHealthDao
,TPacDao
,UserGroupDao
,UserRoleDao
,WorkspaceDao
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
Modifier and TypeFieldDescriptionstatic final int
The default database fetch limit.static final int
The maximum number of parameters that shall be used in a SQL query. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addOrdering
(org.apache.cayenne.query.SelectQuery query, String property) Deprecated.protected void
addOrderingCaseInsensitive
(org.apache.cayenne.query.SelectQuery query, String property) protected void
addOrderingCaseSensitive
(org.apache.cayenne.query.SelectQuery query, String property) protected void
andQueryBetween
(org.apache.cayenne.query.SelectQuery query, String property, Date startDate, Date endDate) protected void
andQueryInExp
(org.apache.cayenne.query.SelectQuery query, String property, Object[] values) protected void
andQueryInExp
(org.apache.cayenne.query.SelectQuery query, String property, Collection<?> values) protected void
andQueryLikeIgnoreCaseExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected void
andQueryMatchDbExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected void
andQueryMatchExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected void
andQueryMatchIsNotNull
(org.apache.cayenne.query.SelectQuery query, String property) protected void
andQueryMatchIsNull
(org.apache.cayenne.query.SelectQuery query, String property) protected void
andQueryNoMatchExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected void
andQueryNotTrue
(org.apache.cayenne.query.SelectQuery query, String property) protected void
deleteObject
(org.apache.cayenne.DataObject dataObject) protected void
deleteObjects
(Collection objects) protected org.apache.cayenne.DataObject
findObject
(Class dataObjectClass, String property, Object value) protected org.apache.cayenne.access.DataContext
int
Return the default query fetch limit.protected org.slf4j.Logger
Return the service log.protected Object
getObjectForPK
(Class dataObjectClass, Object id) protected <T> T
protected void
orQueryLikeIgnoreCaseExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected void
orQueryMatchExp
(org.apache.cayenne.query.SelectQuery query, String property, Object value) protected List
performNamedQuery
(String queryName, boolean refresh) protected List
performNamedQuery
(String queryName, String[] keys, String[] values, boolean refresh) protected List
performNamedQuery
(String queryName, Map parameters) protected List
performNamedQuery
(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 List
performQuery
(Class dataObjectClass, String property, Object value) 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.protected List
performQuery
(org.apache.cayenne.query.SelectQuery query, int fetchLimit) protected void
registerNewObject
(org.apache.cayenne.DataObject dataObject) 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.void
setFetchLimit
(int limit) Set the default query fetch limit.void
setLocalCacheStrategy
(org.apache.cayenne.query.SelectQuery query) Set the application local cache strategy and cache group on the given query.void
setLocalCacheStrategy
(org.apache.cayenne.query.SelectQuery query, String cacheGroup) Set the application local cache strategy and cache group on the given query.void
setSharedCacheStrategy
(org.apache.cayenne.query.SelectQuery query, String cacheGroup) Set the application shared cache strategy and cache group on the given query.protected Map
protected Map
-
Field Details
-
FETCH_LIMIT
public static final int FETCH_LIMITThe default database fetch limit.- See Also:
-
STATEMENT_MAX_NO_PARAMETERS
public static final int STATEMENT_MAX_NO_PARAMETERSThe 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:
-
-
Constructor Details
-
BaseDao
public BaseDao()
-
-
Method Details
-
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
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
-
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
-
deleteObject
protected void deleteObject(org.apache.cayenne.DataObject dataObject) -
deleteObjects
-
getObjectForPK
-
findObject
-
performNonSelectingQuery
protected int[] performNonSelectingQuery(org.apache.cayenne.query.Query query) -
performNonSelectingQuery
-
performNonSelectingQuery
-
performQuery
Perform the given select query and set the default fetch limit, if no fetch limit has been set. -
performQuery
-
performNamedQuery
-
performNamedQuery
-
performNamedQuery
-
performNamedQuery
-
performQuery
-
performNonSelectingQuery
-
toMap
-
toMap
-
andQueryMatchExp
-
andQueryMatchIsNotNull
-
andQueryMatchIsNull
-
andQueryInExp
protected void andQueryInExp(org.apache.cayenne.query.SelectQuery query, String property, Collection<?> values) -
andQueryInExp
-
andQueryNoMatchExp
-
andQueryMatchDbExp
-
andQueryLikeIgnoreCaseExp
-
andQueryBetween
-
orQueryMatchExp
-
orQueryLikeIgnoreCaseExp
-
andQueryNotTrue
-
addOrdering
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)
-