Class BaseDao

java.lang.Object
com.avoka.core.dao.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

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 Details

    • FETCH_LIMIT

      public static final int FETCH_LIMIT
      The default database fetch limit.
      See Also:
    • 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:
  • 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

      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 query
      cacheGroup - 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 query
      cacheGroup - 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 query
      strategy - the strategy for the query
      cacheGroup - 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)
    • getObjectForPK

      protected Object getObjectForPK(Class dataObjectClass, Object id)
    • 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, boolean refresh)
    • performNamedQuery

      protected List performNamedQuery(String queryName, Map parameters)
    • performNamedQuery

      protected List performNamedQuery(String queryName, Map parameters, boolean refresh)
    • performNamedQuery

      protected List performNamedQuery(String queryName, String[] keys, String[] values, boolean refresh)
    • performQuery

      protected List performQuery(Class dataObjectClass, String property, Object value)
    • performNonSelectingQuery

      protected int[] performNonSelectingQuery(String queryName, String[] keys, String[] values)
    • toMap

      protected Map toMap(String key, Object value)
    • toMap

      protected Map toMap(String[] keys, Object[] 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)