X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/1a9182c4c2aeb5f05bd9e45f0d64c9e546f1c0fd..0009185ee385d23193807ed7f36c9517d93fb344:/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java diff --git a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java index 54bd5e7689..82063ddee4 100644 --- a/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java +++ b/cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/common/ICdmEntityDao.java @@ -12,11 +12,15 @@ package eu.etaxonomy.cdm.persistence.dao.common; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; +import org.hibernate.Session; import org.springframework.dao.DataAccessException; import eu.etaxonomy.cdm.model.common.CdmBase; +import eu.etaxonomy.cdm.persistence.dao.BeanInitializer; +import eu.etaxonomy.cdm.persistence.query.OrderHint; /** * an data access interface that all data access classes implement @@ -42,7 +46,13 @@ public interface ICdmEntityDao { */ public UUID save(T newOrManagedObject) throws DataAccessException; - public Map saveAll(Collection cdmObjCollection) throws DataAccessException; + public UUID merge(T transientObject) throws DataAccessException; + + public void clear() throws DataAccessException; + + public Session getSession() throws DataAccessException; + + public Map saveAll(Collection cdmObjCollection) throws DataAccessException; /** * @param transientObject @@ -51,6 +61,13 @@ public interface ICdmEntityDao { */ public UUID update(T transientObject) throws DataAccessException; + /** + * @param persistentObject + * @return + * @throws DataAccessException + */ + public UUID refresh(T persistentObject) throws DataAccessException; + /** * @param persistentObject * @return @@ -61,12 +78,83 @@ public interface ICdmEntityDao { /** * Returns a sublist of CdmBase instances stored in the database. * A maximum of 'limit' objects are returned, starting at object with index 'start'. + * @param limit the maximum number of entities returned (can be null to return all entities) + * @param start + * @return + * @throws DataAccessException + */ + public List list(Integer limit, Integer start) throws DataAccessException; + + /** + * Returns a sublist of CdmBase instances stored in the database. A maximum + * of 'limit' objects are returned, starting at object with index 'start'. + * + * @param limit + * the maximum number of entities returned (can be null to return + * all entities) + * @param start + * @param orderHints + * Supports path like orderHints.propertyNames which + * include *-to-one properties like createdBy.username or + * authorTeam.persistentTitleCache + * @return + * @throws DataAccessException + */ + public List list(Integer limit, Integer start, List orderHints); + + + /** + * Returns a sublist of CdmBase instances stored in the database. A maximum + * of 'limit' objects are returned, starting at object with index 'start'. + * + * @param type * @param limit + * the maximum number of entities returned (can be null to return + * all entities) * @param start + * @param orderHints + * Supports path like orderHints.propertyNames which + * include *-to-one properties like createdBy.username or + * authorTeam.persistentTitleCache * @return * @throws DataAccessException */ - public List list(int limit, int start) throws DataAccessException; + public List list(Class type, Integer limit, Integer start, List orderHints, List propertyPaths); + + /** + * Returns a sublist of CdmBase instances stored in the database. A maximum + * of 'limit' objects are returned, starting at object with index 'start'. + * The bean properties specified by the parameter propertyPaths + * and recursively initialized for each of the entities in the resultset + * + * For detailed description and examples redarding + * propertyPaths please refer to: + * {@link BeanInitializer#initialize(Object, List)} + * + * @param limit + * the maximum number of entities returned (can be null to return + * all entities) + * @param start + * @param orderHints + * Supports path like orderHints.propertyNames which + * include *-to-one properties like createdBy.username or + * authorTeam.persistentTitleCache + * @param propertyPaths + * @return + * @throws DataAccessException + */ + public List list(Integer limit, Integer start, List orderHints, List propertyPaths); + + /** + * Returns a sublist of CdmBase instances of type stored in the database. + * A maximum of 'limit' objects are returned, starting at object with index 'start'. + * @param limit the maximum number of entities returned (can be null to return all entities) + * @param start + * @return + * @throws DataAccessException + */ + public List list(Class type, Integer limit, Integer start) throws DataAccessException; + public List rows(String tableName, int limit, int start) throws DataAccessException; @@ -84,6 +172,45 @@ public interface ICdmEntityDao { */ public T findByUuid(UUID Uuid) throws DataAccessException; + /** + * @param uuidSet + * @return + * @throws DataAccessException + */ + public List findByUuid(Set uuidSet) throws DataAccessException; + + /** + * Finds the cdm entity specified by the uuid parameter and + * initializes all its *ToOne relations. + * + * @param uuid + * @return + */ + public T load(UUID uuid); + + /** + * Finds the cdm entity specified by the uuid parameter and + * recursively initializes all bean properties given in the + * propertyPaths parameter. + *

+ * For detailed description and examples please refer to: + * {@link BeanInitializer#initialize(Object, List)} + * + * @param uuid + * @param propertyPaths properties to be initialized + * @return + */ + public T load(UUID uuid, List propertyPaths); + + + /** + * @param uuidSet + * @param propertyPaths + * @return + * @throws DataAccessException + */ + public List load(Set uuidSet, List propertyPaths) throws DataAccessException; + /** * @param uuid * @return @@ -93,13 +220,24 @@ public interface ICdmEntityDao { public int count(); - public int count(Class clazz); + /** + * Returns the number of objects of type - which must extend T + * @param + * @param clazz + * @return + */ + public int count(Class clazz); /** - * + * FIXME Should this method exist : I would expect flushing of a session to be + * something that a DAO should hide? */ public void flush(); - - + /** + * Convenience method which makes it easy to discover what type of object this DAO returns at runtime + * + * @return + */ + public Class getType(); }