List of usage examples for org.hibernate.boot.registry.internal StandardServiceRegistryImpl getService
@Override
public <R extends Service> R getService(Class<R> serviceRole)
From source file:com.zutubi.pulse.master.hibernate.SchemaRefactor.java
License:Apache License
protected Object executeWithConnection(Callback c) throws SQLException { StandardServiceRegistryImpl serviceRegistry = null; Connection connection = null; try {//from w w w.j a v a 2s. c o m serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder() .applySettings(connectionProperties).build(); connection = serviceRegistry.getService(ConnectionProvider.class).getConnection(); conditionalBuildMappings(); return c.execute(connection); } finally { if (serviceRegistry != null) { serviceRegistry.getService(ConnectionProvider.class).closeConnection(connection); serviceRegistry.destroy(); } } }