Subversion Repositories bacoAlunos

Rev

Rev 1 | Blame | Compare with Previous | Last modification | View Log | RSS feed


package jomm.dao;

import java.util.Collection;
import java.util.List;
import java.io.Serializable;

/**
 * The interface that Data Access Objects must provide for each Hibernate mapped
 * class.
 *
 */

public interface IDomainObjectDao<CLAZZ> extends IDao {
       
        /**
         * Persist the given transient instance, first assigning a generated identifier. (Or
         * using the current value of the identifier property if the <tt>assigned</tt>
         * generator is used.) This operation cascades to associated instances if the
         * association is mapped with <tt>cascade="save-update"</tt>.
         *
         * @param transientObject a transient instance of a persistent class
         * @see  #save(Object)
     * @return Serializable identifier
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
         */

        1.5.0/docs/api/java/io/Serializable.html">Serializable save(CLAZZ transientObject) throws DaoException;
       
        /**
         * Remove a persistent instance from the datastore. The argument may be
         * an instance associated with the receiving <tt>Session</tt> or a transient
         * instance with an identifier associated with existing persistent state.
         * This operation cascades to associated instances if the association is mapped
         * with <tt>cascade="delete"</tt>.
         *
         * @param persistentObject the instance to be removed
         * @throws DaoException if anything goes wrong
         *
         * @see #delete(Object)
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
         */

    void delete(CLAZZ persistentObject) throws DaoException;
       
    /**
     * Count all objects of this DAO's reference class.
     *
     * @return the number of objects persistent by this DAO's reference class
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    long countAll() throws DaoException;
   
    /**
     * Return all objects related to the implementation of this DAO with no filters.
     *
     * @return all objects related to the implementation of this DAO with no filters
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    List<CLAZZ> findAll() throws DaoException;
   
    /**
     * Delete the objects.
     *
     * @param persistentObjects the collection of objects to delete
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    void delete(Collection<CLAZZ> persistentObjects) throws DaoException;
   
    /**
     * Saves a collection of objects without returning the DbKey.
     *
     * To obtain the DbKey, use the object itself.
     *
     * @param transientObjects to save
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    void save(Collection<CLAZZ> transientObjects) throws DaoException;

    /**
     * Used by the base DAO classes but here for your modification Update the
     * persistent state associated with the given identifier. An exception is
     * thrown if there is a persistent instance with the same identifier in the
     * current examples.
     *
     * @param obj
     *            a transient instance containing updated state
     * @throws jomm.dao.DaoException  when Hibernate trwoes Hibernate Exception
     */

    void reattach(CLAZZ obj) throws DaoException;

    /**
     * Loads an object given the DbKey.
     * This method might return a proxied instance that is initialized on-demand, when a non-identifier
     * method is accessed.
     *
     * This method should not be used to determine if an instance exists (use <tt>get()</tt>
     * instead). Use this only to retrieve an instance that you assume exists, where non-existence
     * would be an actual error.
     *
     * @param dbKey to Load
     * @return  Persistent Object
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    CLAZZ load(1.5.0/docs/api/java/io/Serializable.html">Serializable dbKey) throws DaoException;
   
    /**
     * Return the persistent instance of the given entity class with the given identifier,
     * or null if there is no such persistent instance. (If the instance is already associated
     * with the examples, return that instance. This method never returns an uninitialized instance.)
     *
     * @param dbKey to return object
     * @return  Object
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    CLAZZ get(1.5.0/docs/api/java/io/Serializable.html">Serializable dbKey) throws DaoException;
   
    /**
     * Returns results as a page.
     *
     * Finds "sizeOfPage" objects, starting from the page "pageIndex". (Pages start from 0)
     *
     * @param pageIndex page number to load
     * @param sizeOfPage results in page
     * @return  List of objects
     * @throws DaoException
     * <BR><B>author <a href="mailto:luismmribeiro@gmail.com">Luis Ribeiro</a></B>
     */

    List<CLAZZ> findByPage(int pageIndex, int sizeOfPage) throws DaoException;

     /**
     *
     * @param maxField field to find max to load object
     * @return last inserted object
     */

    CLAZZ getLast(1.5.0/docs/api/java/lang/String.html">String maxField);

    /**
     *
     * @param field of HQL to find id
     * @return max id or ZERO if dont exist
     */

    CLAZZ findMaxId(1.5.0/docs/api/java/lang/String.html">String field);
}