hibernate-reactive
hibernate-reactive copied to clipboard
Support the `StatementInspector` API
Based on this question on StackOverflow, we don't support the StatementInspector API.
It seems something useful to have, but I haven't looked into it yet.
We should:
- Check that it actually doesn't work
- Figure out how to make it work, if there's an alternative, or if it makes sense to have it
I think it's fair to say that StatementInspector doesn't work with Hibernate Reactive currently.
As a workaround, this should work:
You could create a wrapper around ReactiveConnection and intercepts all the calls related to the execution of the query.
For example, you can have:
public class ConnectionInterceptor implements ReactiveConnection {
private final ReactiveConnection delegate;
public ConnectionInterceptor(ReactiveConnection delegate) {
this.delegate = delegate;
}
public CompletionStage<Void> execute(String sql) {
String newSql = convert(sql);
return delegate.execute(newSql);
}
// ... You need to implement all the other methods running a query
}
package my.example;
public class MyPool extends DefaultSqlClientPool {
public CompletionStage<ReactiveConnection> getConnection() {
return super.getConnection().thenApply( ConnectionInterceptor::new );
}
}
You can register the new pool class using the property hibernate.vertx.pool.class:
hibernate.vertx.pool.class = my.example.MyPool