Example usage for org.hibernate.boot.registry.internal StandardServiceRegistryImpl destroy

List of usage examples for org.hibernate.boot.registry.internal StandardServiceRegistryImpl destroy

Introduction

In this page you can find the example usage for org.hibernate.boot.registry.internal StandardServiceRegistryImpl destroy.

Prototype

@Override
    public synchronized void destroy() 

Source Link

Usage

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 {//ww  w . j a  v  a  2  s. co 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();
        }
    }
}