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

import org.hibernate.Session;
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(
                                 "/com/toscana/config/hibernate.cfg.xml"
                                 ).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;
    }

    public static Session beginTransaction() {
        Session hibernateSession = ToscanaHibernateUtil.getSession();
        hibernateSession.beginTransaction();
        return hibernateSession;
    }

    public static void commitTransaction() {
        ToscanaHibernateUtil.getSession().getTransaction().commit();
    }

    public static void rollbackTransaction() {
        ToscanaHibernateUtil.getSession().getTransaction().rollback();
    }

    public static void closeSession() {
        ToscanaHibernateUtil.getSession().close();
    }

    public static Session getSession() {
        Session hibernateSession = sessionFactory.getCurrentSession();
        return hibernateSession;
    }
    
    public static void main(String[] args) {
        Session session = ToscanaHibernateUtil.getSession();
        session.toString();
    }
}

@@ -187,35 +187,22 @@
 ate.
-cfg.AnnotationConfiguration
+SessionFactory
 ;%0Aim
@@ -220,30 +220,33 @@
 bernate.
-SessionFactory
+cfg.Configuration
 ;%0A%0A/**%0A 
@@ -617,18 +617,8 @@
 new 
-Annotation
 Conf

Fix hibernate util