properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
// build the serviceregistry
final BootstrapServiceRegistryBuilder bootstrapbuilder = new BootstrapServiceRegistryBuilder();
builder = new ServiceRegistryBuilder(bootstrapbuilder.build()).applySettings(properties);
serviceRegistry = builder.buildServiceRegistry();
// Create the SessionFactory from Configuration
sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory(serviceRegistry);
} catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed