Interface GenericDAO<T>

Type Parameters:
T - type which is accessed by this DAO, for example Item.
All Known Subinterfaces:
BitstreamDAO, BitstreamFormatDAO, BundleDAO, ChecksumHistoryDAO, ChecksumResultDAO, ClaimedTaskDAO, CollectionDAO, CollectionRoleDAO, CommunityDAO, DOIDAO, DSpaceObjectDAO<T>, DSpaceObjectLegacySupportDAO<T>, EntityTypeDAO, EPersonDAO, Group2GroupCacheDAO, GroupDAO, HandleDAO, HarvestedCollectionDAO, HarvestedItemDAO, InProgressUserDAO, ItemDAO, LDNMessageDao, MetadataFieldDAO, MetadataSchemaDAO, MetadataValueDAO, MostRecentChecksumDAO, NotifyPatternToTriggerDao, NotifyServiceDao, NotifyServiceInboundPatternDao, OpenURLTrackerDAO, OrcidHistoryDAO, OrcidQueueDAO, OrcidTokenDAO, PoolTaskDAO, ProcessDAO, QAEventsDAO, RegistrationDataDAO, RegistrationDataMetadataDAO, RelationshipDAO, RelationshipTypeDAO, RequestItemDAO, ResourcePolicyDAO, SiteDAO, SubscriptionDAO, SubscriptionParameterDAO, SupervisionOrderDao, SystemWideAlertDAO, VersionDAO, VersionHistoryDAO, WebAppDAO, WorkflowItemRoleDAO, WorkspaceItemDAO, XmlWorkflowItemDAO
All Known Implementing Classes:
AbstractHibernateDAO, AbstractHibernateDSODAO, BitstreamDAOImpl, BitstreamFormatDAOImpl, BundleDAOImpl, ChecksumHistoryDAOImpl, ChecksumResultDAOImpl, ClaimedTaskDAOImpl, CollectionDAOImpl, CollectionRoleDAOImpl, CommunityDAOImpl, DOIDAOImpl, EntityTypeDAOImpl, EPersonDAOImpl, Group2GroupCacheDAOImpl, GroupDAOImpl, HandleDAOImpl, HarvestedCollectionDAOImpl, HarvestedItemDAOImpl, InProgressUserDAOImpl, ItemDAOImpl, LDNMessageDaoImpl, MetadataFieldDAOImpl, MetadataSchemaDAOImpl, MetadataValueDAOImpl, MostRecentChecksumDAOImpl, NotifyPatternToTriggerDaoImpl, NotifyServiceDaoImpl, NotifyServiceInboundPatternDaoImpl, OpenURLTrackerDAOImpl, OrcidHistoryDAOImpl, OrcidQueueDAOImpl, OrcidTokenDAOImpl, PoolTaskDAOImpl, ProcessDAOImpl, QAEventsDAOImpl, RegistrationDataDAOImpl, RegistrationDataMetadataDAOImpl, RelationshipDAOImpl, RelationshipTypeDAOImpl, RequestItemDAOImpl, ResourcePolicyDAOImpl, SiteDAOImpl, SubscriptionDAOImpl, SubscriptionParameterDAOImpl, SupervisionOrderDaoImpl, SystemWideAlertDAOImpl, VersionDAOImpl, VersionHistoryDAOImpl, WebAppDAOImpl, WorkflowItemRoleDAOImpl, WorkspaceItemDAOImpl, XmlWorkflowItemDAOImpl

public interface GenericDAO<T>
Generic Database Access Object interface class that should be implemented by all DAOs. It offers up a lot of general methods so these don't need to be declared again in each DAO. The default Hibernate implementation offers up a class that implements all these methods.
Author:
kevinvandevelde at atmire.com
  • Method Details

    • create

      T create(Context context, T t) throws SQLException
      Create a new instance of this type in the database.
      Parameters:
      context - current DSpace context.
      t - type to be created.
      Returns:
      entity tracking the created instance.
      Throws:
      SQLException
    • save

      void save(Context context, T t) throws SQLException
      Persist this instance in the database.
      Parameters:
      context - current DSpace context.
      t - type created here.
      Throws:
      SQLException - passed through.
    • delete

      void delete(Context context, T t) throws SQLException
      Remove an instance from the database.
      Parameters:
      context - current DSpace context.
      t - type of the instance to be removed.
      Throws:
      SQLException - passed through.
    • findAll

      List<T> findAll(Context context, Class<T> clazz) throws SQLException
      Fetch all persisted instances of a given object type.
      Parameters:
      context - The relevant DSpace Context.
      clazz - the desired type.
      Returns:
      list of DAOs of the same type as clazz
      Throws:
      SQLException - if database error
    • findAll

      List<T> findAll(Context context, Class<T> clazz, Integer limit, Integer offset) throws SQLException
      Fetch all persisted instances of a given object type.
      Parameters:
      context - The relevant DSpace Context.
      clazz - the desired type.
      limit - paging limit
      offset - paging offset
      Returns:
      list of DAOs of the same type as clazz
      Throws:
      SQLException - if database error
    • findUnique

      T findUnique(Context context, String query) throws SQLException
      Execute a JPQL query returning a unique result.
      Parameters:
      context - The relevant DSpace Context.
      query - JPQL query string
      Returns:
      a DAO specified by the query string
      Throws:
      SQLException - if database error
    • findByID

      T findByID(Context context, Class clazz, int id) throws SQLException
      Fetch the entity identified by its legacy database identifier.
      Parameters:
      context - current DSpace context.
      clazz - class of entity to be found.
      id - legacy database record ID.
      Returns:
      the found entity.
      Throws:
      SQLException - passed through.
    • findByID

      T findByID(Context context, Class clazz, UUID id) throws SQLException
      Fetch the entity identified by its UUID primary key.
      Parameters:
      context - current DSpace context.
      clazz - class of entity to be found.
      id - primary key of the database record.
      Returns:
      the found entity.
      Throws:
      SQLException
    • findByID

      T findByID(Context context, Class clazz, String id) throws SQLException
      Fetch the entity identified by its String primary key.
      Parameters:
      context - current DSpace context.
      clazz - class of entity to be found.
      id - primary key of the database record.
      Returns:
      the found entity.
      Throws:
      SQLException
    • findMany

      List<T> findMany(Context context, String query) throws SQLException
      Execute a JPQL query and return a collection of results.
      Parameters:
      context - The relevant DSpace Context.
      query - JPQL query string
      Returns:
      list of DAOs specified by the query string
      Throws:
      SQLException - if database error