Subclass the org.hibernate.connection.DatasourceConnectionProvider, override the getConnection() method, and place your commands there:
Code:
@Override
public Connection getConnection() throws SQLException {
Connection conn = super.getConnection();
// do whatever stuff you need with this connection
return conn;
}
Then declare your class as the connection provider in hibernate.properties (or whatever you use to configure Hibernate):
hibernate.connection.provider_class=your.class.goes.here
HTH,
Alex