// Fetch and pre-process the Hibernate mapping descriptors.
loadHibernateDescriptors(hbmConfig);
// Initialize the Hibernate session factory.
ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(hbmConfig.getProperties());
ServiceRegistry serviceRegistry = (ServiceRegistry) ReflectionUtils.invokeMethod(serviceRegistryBuilder, "buildServiceRegistry", null);
if (serviceRegistry == null) serviceRegistry = (ServiceRegistry) ReflectionUtils.invokeMethod(serviceRegistryBuilder, "build", null);
SessionFactory factory = hbmConfig.buildSessionFactory(serviceRegistry);
hibernateSessionFactoryProvider.setSessionFactory(factory);