Type ServiceRegistryBuilder deprecated hibernate

Type ServiceRegistryBuilder deprecated hibernate

The type ServiceRegistryBuilder is deprecated

With new version of Hibernate 4.3 ServiceRegistryBuilder is deprecated use StandardServiceRegistryBuilder as below:

serviceRegistry = new StandardServiceRegistryBuilder().applySettings(

Complete Java utility class to create SessionFactory:

package com.javahonk.util;

import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

public class HibernateUtil {
    private static SessionFactory sessionFactory = 
    private static ServiceRegistry serviceRegistry;

    private static SessionFactory buildSessionFactory() {
        try {
            Configuration configuration = new Configuration();
            //Use config file path explicitly 
            serviceRegistry = new StandardServiceRegistryBuilder()
            sessionFactory = configuration
            return sessionFactory;
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory "
                    + "creation failed." + ex);
            throw new ExceptionInInitializerError(ex);

    public static SessionFactory getSessionFactory() {
        return sessionFactory;

    public static void shutdown() {
        // Close caches and connection pools

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *