Package org.dspace.core
Class AbstractHibernateDSODAO<T extends DSpaceObject>
- java.lang.Object
-
- org.dspace.core.AbstractHibernateDAO<T>
-
- org.dspace.core.AbstractHibernateDSODAO<T>
-
- Type Parameters:
T- type of DSO represented.
- All Implemented Interfaces:
GenericDAO<T>
- Direct Known Subclasses:
BitstreamDAOImpl,BundleDAOImpl,CollectionDAOImpl,CommunityDAOImpl,EPersonDAOImpl,GroupDAOImpl,ItemDAOImpl
public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends AbstractHibernateDAO<T>
Hibernate implementation used by DSpaceObject Database Access Objects. Includes commonly used methods.Each DSO Database Access Object should extend this class to prevent code duplication.
- Author:
- kevinvandevelde at atmire.com
-
-
Constructor Summary
Constructors Constructor Description AbstractHibernateDSODAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddMetadataLeftJoin(StringBuilder query, String tableIdentifier, Collection<MetadataField> metadataFields)Add left outer join on all metadata fields which are passed to this function.protected voidaddMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields)Append ORDER BY clause based on metadata fields or column names.protected voidaddMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields, List<String> direction)Append ORDER BY clause based on metadata fields or column names.protected voidaddMetadataValueWhereQuery(StringBuilder query, List<MetadataField> metadataFields, String operator, String additionalWhere)Using the metadata tables mapped in the leftJoin, this function creates a where query which can check the values.TfindByLegacyId(Context context, int legacyId, Class<T> clazz)Find a DSO by its "legacy ID".-
Methods inherited from class org.dspace.core.AbstractHibernateDAO
count, count, countLong, create, createQuery, delete, executeCriteriaQuery, findAll, findAll, findByID, findByID, findByX, findMany, findMany, findUnique, getCriteriaBuilder, getCriteriaQuery, getHibernateSession, iterate, list, list, list, list, save, singleResult, singleResult, uniqueResult, uniqueResult
-
-
-
-
Method Detail
-
findByLegacyId
public T findByLegacyId(Context context, int legacyId, Class<T> clazz) throws SQLException
Find a DSO by its "legacy ID". Former versions of DSpace used integer record IDs, and these may still be found in external records such as AIPs. All DSOs now have UUID primary keys, and those should be used when available. Each type derived from DSpaceObject had its own stream of record IDs, so it is also necessary to know the specific type.- Parameters:
context- current DSpace context.legacyId- the old integer record identifier.clazz- DSO subtype of record identified bylegacyId.- Returns:
- Throws:
SQLException
-
addMetadataLeftJoin
protected void addMetadataLeftJoin(StringBuilder query, String tableIdentifier, Collection<MetadataField> metadataFields)
Add left outer join on all metadata fields which are passed to this function. The identifier of the join will be the toString() representation of the metadata field. The joined metadata fields can then be used to query or sort.- Parameters:
query- the query string being built.tableIdentifier- name of the table to be joined.metadataFields- names of the desired fields.
-
addMetadataValueWhereQuery
protected void addMetadataValueWhereQuery(StringBuilder query, List<MetadataField> metadataFields, String operator, String additionalWhere)
Using the metadata tables mapped in the leftJoin, this function creates a where query which can check the values. Values can be checked using a like or an "=" query, as determined by the "operator" parameter. When creating a query, the "queryParam" string can be used set as parameter for the query.- Parameters:
query- the already existing query builder, all changes will be appendedmetadataFields- the metadata fields whose metadata value should be queriedoperator- can either be "=" or "like"additionalWhere- additional where query
-
addMetadataSortQuery
protected void addMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields)
Append ORDER BY clause based on metadata fields or column names. All fields will be in ascending order.- Parameters:
query- the query being built.metadataSortFields- fields on which to sort -- use this OR columnSortFields.columnSortFields- columns on which to sort -- use this OR metadataSortFields.
-
addMetadataSortQuery
protected void addMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields, List<String> direction)
Append ORDER BY clause based on metadata fields or column names.- Parameters:
query- the query being built.metadataSortFields- fields on which to sort -- use this OR columnSortFields.columnSortFields- columns on which to sort -- use this OR metadataSortFields.direction- ASC or DESC for each field. Unspecified fields will be ASC.
-
-