Witam, mam problem ponieważ mój program który używa hibernate nie kończy działania. Znalazłem podobny problem tu: http://stackoverflow.com/ques[...]-hibernate-does-not-terminate lecz i to nie pomaga.
Plik HibernateUtil

public class HibernateUtil {

    private static SessionFactory factory = null;
    private static StandardServiceRegistry serviceRegistry;

    public static SessionFactory getSessionFactory() {
        if (factory == null) {
            Configuration configuration = new Configuration()
                    .configure("hibernate.cfg.xml");
            serviceRegistry = new StandardServiceRegistryBuilder()
                    .applySettings(configuration.getProperties()).build();
            factory = configuration.buildSessionFactory(serviceRegistry);
            configuration
                    .setSessionFactoryObserver(new SessionFactoryObserver() {
                        public void sessionFactoryCreated(SessionFactory factory) {
                        }
                        public void sessionFactoryClosed(SessionFactory factory) {
                            ((StandardServiceRegistryImpl) serviceRegistry).destroy();
                        }
                    });
        }
        return factory;
    }
    private HibernateUtil() {

    }
}

Plik Main

public class Main {
    public static void main(String[] args) {
        HibernateUtil.getSessionFactory();
    }

}