/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.toscana.util;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory;

/**
 * Hibernate Utility class with a convenient method to get Session Factory
 * object.
 *
 * @author Arandi
 */
public class ToscanaHibernateUtil {

    private static final SessionFactory sessionFactory;
    
    static {
        try {
            // Create the SessionFactory from standard (hibernate.cfg.xml) 
            // config file.
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Log the exception. 
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
    
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

@@ -120,16 +120,46 @@
 .util;%0A%0A
+import org.hibernate.Session;%0A
 import o
@@ -992,10 +992,787 @@
 ;%0A    %7D%0A
+    public static Session beginTransaction() %7B%0A            Session hibernateSession = ToscanaHibernateUtil.getSession();%0A            hibernateSession.beginTransaction();%0A            return hibernateSession;%0A        %7D%0A %0A        public static void commitTransaction() %7B%0A            ToscanaHibernateUtil.getSession().getTransaction().commit();%0A        %7D%0A %0A        public static void rollbackTransaction() %7B%0A            ToscanaHibernateUtil.getSession().getTransaction().rollback();%0A        %7D%0A %0A        public static void closeSession() %7B%0A            ToscanaHibernateUtil.getSession().close();%0A        %7D%0A %0A        public static Session getSession() %7B%0A            Session hibernateSession = sessionFactory.getCurrentSession();%0A            return hibernateSession;%0A        %7D        %0A
 %7D%0A

Update ToscanaHibernateUtil