Author: azeez
Date: Tue Feb 12 07:19:35 2008
New Revision: 13656

Log:

Fixing hibernate related bugs



Modified:
   
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadHibernateConfig.java
   
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadPersistenceManager.java

Modified: 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadHibernateConfig.java
==============================================================================
--- 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadHibernateConfig.java
    (original)
+++ 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadHibernateConfig.java
    Tue Feb 12 07:19:35 2008
@@ -26,7 +26,6 @@
  */
 public class ChadHibernateConfig {
     public final SessionFactory SESSION_FACTORY;
-//    public final ThreadLocal SESSION = new ThreadLocal();
 
     /**
      * Default Constructor. This should be package protected since we should 
only instantiate it
@@ -50,21 +49,6 @@
     
     public Session currentSession() throws HibernateException {
         return SESSION_FACTORY.getCurrentSession();
-        /*Session session = (Session) SESSION.get();
-        if (session == null) {
-            session = SESSION_FACTORY.openSession();
-            SESSION.set(session);
-        }
-        return session;*/
-    }
-
-    public void closeSession() throws HibernateException {
-        SESSION_FACTORY.getCurrentSession().close();
-//        Session session = (Session) SESSION.get();
-//        if (session != null) {
-//            session.close();
-//        }
-//        SESSION.set(null);
     }
 }
 

Modified: 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadPersistenceManager.java
==============================================================================
--- 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadPersistenceManager.java
 (original)
+++ 
trunk/wsas/java/modules/samples/Chad/src/org/wso2/wsas/sample/chad/data/ChadPersistenceManager.java
 Tue Feb 12 07:19:35 2008
@@ -59,7 +59,6 @@
         adminUser.setLastUpdatedTime(new Date());
         try {
             session.persist(adminUser);
-            session.flush();
             tx.commit();
         } catch (ConstraintViolationException e) {
             String msg = "Administrator " + username.trim() + " already 
exists";
@@ -68,8 +67,6 @@
         } catch (Exception e) {
             tx.rollback();
             throw new RuntimeException("Cannot create Administrator account", 
e);
-        } finally {
-            hbConfig.closeSession();
         }
     }
 
@@ -92,8 +89,6 @@
             tx.commit();
         } catch (Throwable t) {
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
     }
 
@@ -116,11 +111,10 @@
             log.warn(msg, e);
             throw new DuplicatePollException(msg, e);
         } catch (Exception e) {
+            e.printStackTrace();
             tx.rollback();
             throw new RuntimeException("Cannot create entity", e);
-        } finally {
-            hbConfig.closeSession();
-        }
+        } 
     }
 
     /**
@@ -139,10 +133,9 @@
             admin = (AdminUser) criteria.uniqueResult();
             session.evict(admin);
             tx.commit();
-        } catch (Throwable t) {
+        } catch (Throwable e) {
+            e.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
         return admin;
     }
@@ -173,9 +166,8 @@
         } catch (ChadAuthenticationException e) {
             throw e;
         } catch (Throwable t) {
+            t.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
     }
 
@@ -196,9 +188,8 @@
             session.evict(poll);
             tx.commit();
         } catch (Throwable t) {
+            t.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
         return poll;
     }
@@ -221,9 +212,8 @@
                 users[i++] = ((AdminUser) iterator.next()).getUsername();
             }
         } catch (Throwable e) {
+            e.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
         return users;
     }
@@ -243,9 +233,8 @@
             polls = (ChadPoll[]) list.toArray(new ChadPoll[list.size()]);
             tx.commit();
         } catch (Throwable t) {
+            t.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
         return polls;
     }
@@ -262,9 +251,8 @@
             session.update(poll);
             tx.commit();
         } catch (Throwable t) {
+            t.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
     }
 
@@ -327,9 +315,8 @@
             }
             tx.commit();
         } catch (Throwable t) {
+            t.printStackTrace();
             tx.rollback();
-        } finally {
-            hbConfig.closeSession();
         }
         return result;
     }

_______________________________________________
Wsas-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev

Reply via email to