Salome HOME
The draft of the "Copy from existing study" action is added. The YACS step is introdu...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / dao / kernel / AbstractGenericDAOImpl.java
index 64996b4234c6b3d042390bb9c30ec18b079bc615..393c124a2fa8bcecb9fd720f7610a3ec80d8e0f3 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Properties;
 
 import org.hibernate.Criteria;
 import org.hibernate.LockOptions;
+import org.hibernate.Session;
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.DetachedCriteria;
 import org.hibernate.criterion.Order;
@@ -44,6 +45,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         * @param newInstance
         *            new object as a transient instance
         * @return new primary key for the created persistent object
+        * @see Session#save(Object)
         */
        @SuppressWarnings(UNCHECKED)
        public PK create(final T newInstance) {
@@ -55,6 +57,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         * 
         * @param newInstance
         *            new object as a transient instance
+        * @see Session#saveOrUpdate(Object)
         */
        @SuppressWarnings(UNCHECKED)
        public void saveOrUpdate(final T newInstance) {
@@ -67,6 +70,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         * @param id
         *            primary key of an object to read
         * @return an object found by the given key
+        * @see Session#get(Class, Serializable)
         */
        @SuppressWarnings(UNCHECKED)
        public T get(final PK id) {
@@ -142,6 +146,21 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
                return aDetachedCriteria.getExecutableCriteria(getSession()).list();
        }
 
+       /**
+        * Retrieve a list of DTO objects using the given criteria.
+        * 
+        * @param <DTO>
+        *            the class of returned DTOs
+        * @param aDetachedCriteria
+        *            search criteria
+        * @return a list of DTO objects filtered according to the given criteria
+        */
+       @SuppressWarnings(UNCHECKED)
+       public <DTO> List<DTO> getFilteredDTOList(
+                       final DetachedCriteria aDetachedCriteria) {
+               return aDetachedCriteria.getExecutableCriteria(getSession()).list();
+       }
+
        /**
         * Retrieve a list of objects which were previously persisted to the database using the given criteria.
         * 
@@ -260,6 +279,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         * 
         * @param transientObject
         *            transient instance of the object to refresh
+        * @see Session#refresh(Object)
         */
        public void refresh(final T transientObject) {
                getSession().refresh(transientObject);
@@ -272,6 +292,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         *            transient instance of the object to load
         * @param id
         *            object primary key
+        * @see Session#load(Object, Serializable)
         */
        public void load(final T transientObject, final PK id) {
                getSession().load(transientObject, id);
@@ -284,6 +305,7 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         *            transient instance of the object to lock
         * @param lockOptions
         *            lock options
+        * @see Session#refresh(Object, LockOptions)
         */
        public void refresh(final T transientObject, final LockOptions lockOptions) {
                getSession().refresh(transientObject, lockOptions);
@@ -294,35 +316,61 @@ public abstract class AbstractGenericDAOImpl<T, PK extends Serializable>
         * 
         * @param persistentObject
         *            a persistent object to delete from the database
+        * @see Session#delete(Object)
         */
        public void delete(final T persistentObject) {
                getSession().delete(persistentObject);
        }
 
        /**
-        * Makes detached object persistent.
+        * Make a transient instance persistent. This operation cascades to <BR>
+        * associated instances if the association is mapped with cascade="persist".
         * 
         * @param transientObject
         *            transient instance of the object to be made persistent
+        * @see Session#persist(Object)
         */
        public void persist(final T transientObject) {
                getSession().persist(transientObject);
        }
 
        /**
-        * Merge detached object with persistent data.
+        * Copy the state of the given object onto the persistent object with the <BR>
+        * same identifier. If there is no persistent instance currently associated<BR>
+        * with the session, it will be loaded. Return the persistent instance. If <BR>
+        * the given instance is unsaved, save a copy of and return it as a newly <BR>
+        * persistent instance. The given instance does not become associated with <BR>
+        * the session. This operation cascades to associated instances if the <BR>
+        * association is mapped with cascade="merge".
         * 
         * @param transientObject
         *            transient instance of the object to be merged with persistent data
         * @return merged persistent object
+        * @see Session#merge(Object)
         */
        @SuppressWarnings(UNCHECKED)
        public T merge(final T transientObject) {
                return (T) getSession().merge(transientObject);
        }
 
+       /**
+        * Remove this instance from the session cache. Changes to the instance will<BR>
+        * not be synchronized with the database. This operation cascades to <BR>
+        * associated instances if the association is mapped with cascade="evict".
+        * 
+        * @param persistentObject
+        *            the object to be removed from session cache
+        * @see Session#evict(Object)
+        */
+       @SuppressWarnings(UNCHECKED)
+       public void evict(final T persistentObject) {
+               getSession().evict(persistentObject);
+       }
+
        /**
         * Synchronize the session data with the database.
+        * 
+        * @see Session#flush()
         */
        public void flush() {
                getSession().flush();