Class BaseDao
- Direct Known Subclasses:
AbstractDao,ApplicationFormDao,ApplicationPackageDao,ApplicationServiceDao,ClientReconciliationFileDao,ClientRefDataDao,JobEventLogDao,JobPropertyDao,JobPropertySearchDao,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
FieldsModifier and TypeFieldDescriptionstatic final intThe default database fetch limit.static final intThe maximum number of parameters that shall be used in a SQL query. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.DataContextintReturn the default query fetch limit.protected org.slf4j.LoggerReturn the service log.protected ObjectgetObjectForPK(Class dataObjectClass, Object id) protected <T> Tprotected 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 Mapprotected 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)
-