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
*/
public UUID save(T newOrManagedObject) throws DataAccessException;
- public Map<UUID, T> saveAll(Collection<T> cdmObjCollection) throws DataAccessException;
+ public UUID merge(T transientObject) throws DataAccessException;
+
+ public void clear() throws DataAccessException;
+
+ public Session getSession() throws DataAccessException;
+
+ public Map<UUID, T> saveAll(Collection<T> cdmObjCollection) throws DataAccessException;
/**
* @param transientObject
*/
public UUID update(T transientObject) throws DataAccessException;
+ /**
+ * @param persistentObject
+ * @return
+ * @throws DataAccessException
+ */
+ public UUID refresh(T persistentObject) throws DataAccessException;
+
/**
* @param persistentObject
* @return
/**
* 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<T> 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 <code>orderHints.propertyNames</code> which
+ * include *-to-one properties like createdBy.username or
+ * authorTeam.persistentTitleCache
+ * @return
+ * @throws DataAccessException
+ */
+ public List<T> list(Integer limit, Integer start, List<OrderHint> 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 <code>orderHints.propertyNames</code> which
+ * include *-to-one properties like createdBy.username or
+ * authorTeam.persistentTitleCache
* @return
* @throws DataAccessException
*/
- public List<T> list(int limit, int start) throws DataAccessException;
+ public <TYPE extends T> List<TYPE> list(Class<TYPE> type, Integer limit, Integer start, List<OrderHint> orderHints, List<String> 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 <code>propertyPaths</code>
+ * and recursively initialized for each of the entities in the resultset
+ *
+ * For detailed description and examples redarding
+ * <code>propertyPaths</code> <b>please refer to:</b>
+ * {@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 <code>orderHints.propertyNames</code> which
+ * include *-to-one properties like createdBy.username or
+ * authorTeam.persistentTitleCache
+ * @param propertyPaths
+ * @return
+ * @throws DataAccessException
+ */
+ public List<T> list(Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
+
+ /**
+ * Returns a sublist of CdmBase instances of type <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 <TYPE extends T> List<TYPE> list(Class<TYPE> type, Integer limit, Integer start) throws DataAccessException;
+
public List<T> rows(String tableName, int limit, int start) throws DataAccessException;
*/
public T findByUuid(UUID Uuid) throws DataAccessException;
+ /**
+ * @param uuidSet
+ * @return
+ * @throws DataAccessException
+ */
+ public List<T> findByUuid(Set<UUID> uuidSet) throws DataAccessException;
+
+ /**
+ * Finds the cdm entity specified by the <code>uuid</code> parameter and
+ * initializes all its *ToOne relations.
+ *
+ * @param uuid
+ * @return
+ */
+ public T load(UUID uuid);
+
+ /**
+ * Finds the cdm entity specified by the <code>uuid</code> parameter and
+ * recursively initializes all bean properties given in the
+ * <code>propertyPaths</code> parameter.
+ * <p>
+ * For detailed description and examples <b>please refer to:</b>
+ * {@link BeanInitializer#initialize(Object, List)}
+ *
+ * @param uuid
+ * @param propertyPaths properties to be initialized
+ * @return
+ */
+ public T load(UUID uuid, List<String> propertyPaths);
+
+
+ /**
+ * @param uuidSet
+ * @param propertyPaths
+ * @return
+ * @throws DataAccessException
+ */
+ public List<T> load(Set<UUID> uuidSet, List<String> propertyPaths) throws DataAccessException;
+
/**
* @param uuid
* @return
public int count();
- public int count(Class clazz);
+ /**
+ * Returns the number of objects of type <TYPE> - which must extend T
+ * @param <TYPE>
+ * @param clazz
+ * @return
+ */
+ public <TYPE extends T> int count(Class<TYPE> 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<T> getType();
}