Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.persistencia.utility; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; /** * Hibernate Utility class with a convenient method to get Session Factory * object. * * @author Usuario */ public class HibernateUtil { private static SessionFactory sessionFactory; private HibernateUtil() { } public static SessionFactory getSessionFactory() { if (sessionFactory == null) { sessionFactory = new Configuration().configure().buildSessionFactory(); } return sessionFactory; } }