What is the importance of StandardServiceRegistry in Hibernate 4?
hibernate, java
Solution
Hibernate 4 has now a plug-in mechanism for registering internal services (connection provider, transaction management).
Therefore you could customize how the services are going to be retrieved (e.g. OSGI), so having this option allows for maximum session factory customizability.
Problem
From Hibernate 4 onwards `Configuration.buildSessionFactory()` was replaced by `Configuration.buildSessionFactory(ServiceRegistry)`. So we have to create session factory like this: ``` private static SessionFactory sessionFactory = null; private static StandardServiceRegistry reg; private static final String TAG = new String("HIBERNATE_UTIL: "); public HibernateUtil() { try { Configuration cfg = new Configuration().configure("/com/dorm/service/hibernate.cfg.xml"); StandardServiceRegistryBuilder reg_builder = new StandardServiceRegistryBuilder(); reg_builder.applySettings(cfg.getProperties()); reg = reg_builder.build(); sessionFactory = cfg.buildSessionFactory(reg); System.out.println(TAG+"Session Factory created"); }catch(HibernateException he) { System.out.println(TAG+"Error in creating Session Factory"); he.printStackTrace(); } } ``` I want to know, What does `StandardServiceRegistry` do? What is the importance of passing an object of `StandardServiceRegistry` in `configuration.buildSessionFactory()` method. Thanks in advance for answers. EDIT: I have referred javadocs of hibernate, but couldn't understand this concept.