more functionality in StorageService and creation of TopicService
authoridfx <idfx>
Tue, 30 Sep 2003 19:27:10 +0000 (19:27 +0000)
committeridfx <idfx>
Tue, 30 Sep 2003 19:27:10 +0000 (19:27 +0000)
source/mir/core/service/storage/StorageService.java
source/mir/core/service/storage/TopicService.java

index 32043b5..03b9ad4 100755 (executable)
@@ -48,7 +48,7 @@ import net.sf.hibernate.expression.Order;
  * 
  * StorageService
  * @author idefix
- * @version $Id: StorageService.java,v 1.6 2003/09/18 21:39:42 idfx Exp $
+ * @version $Id: StorageService.java,v 1.7 2003/09/30 19:27:10 idfx Exp $
  */
 public abstract class StorageService {
        private final int defaultLimit;
@@ -138,6 +138,37 @@ public abstract class StorageService {
                        throw new StorageServiceFailure(e);
                }
        }
+
+       /**
+        * Load a list of Objects from the database
+        * @return a list of Objects
+        */
+       public List list() {
+               try {
+                       Session session = null;
+                       Transaction transaction = null;
+                       try {
+                               session = sessionHolder.currentSession();
+                               transaction = session.beginTransaction();
+                               Criteria criteria = session.createCriteria(objectClass);
+                               List returnList = criteria.list();
+                               transaction.commit();
+                               return returnList;
+                       } catch (HibernateException e) {
+                               if(transaction != null){
+                                       transaction.rollback();
+                               }
+                               throw new StorageServiceFailure(e);
+                       } finally {
+                               if (session != null) {
+                                       sessionHolder.closeSession();
+                               }
+                       }
+               } catch (Exception e){
+                       throw new StorageServiceFailure(e);
+               }
+       }
+
        
        /**
         * Load a Object with the given unique identifier
index caa4fe2..f03db6c 100755 (executable)
 package mir.core.service.storage;
 
 import mir.core.model.Topic;
-import net.sf.hibernate.Hibernate;
 import net.sf.hibernate.HibernateException;
 import net.sf.hibernate.SessionFactory;
 
 /**
  * TopicService
  * @author idefix
- * @version $Id: TopicService.java,v 1.2 2003/09/05 20:23:59 idfx Exp $
+ * @version $Id: TopicService.java,v 1.3 2003/09/30 19:27:10 idfx Exp $
  */
 public class TopicService extends StorageService {
 
@@ -55,10 +54,6 @@ public class TopicService extends StorageService {
         * @see mir.core.service.storage.StorageService#initializeLazyCollections(java.lang.Object)
         */
        protected void initializeLazyCollections(Object returnObject) throws HibernateException {
-               if(returnObject instanceof Topic){
-                       Topic topic = (Topic)returnObject;
-                       Hibernate.initialize(topic.getContent());
-               }
        }
 
 }