Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the StatementInspector API #1700

Open
DavideD opened this issue Jul 7, 2023 · 1 comment
Open

Support the StatementInspector API #1700

DavideD opened this issue Jul 7, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers problem A limitation or source of discomfort

Comments

@DavideD
Copy link
Member

DavideD commented Jul 7, 2023

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:

  1. Check that it actually doesn't work
  2. Figure out how to make it work, if there's an alternative, or if it makes sense to have it
@DavideD DavideD added enhancement New feature or request good first issue Good for newcomers labels Jul 7, 2023
@DavideD
Copy link
Member Author

DavideD commented Nov 5, 2024

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

Taken from this SO answer.

@DavideD DavideD added problem A limitation or source of discomfort and removed problem A limitation or source of discomfort labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers problem A limitation or source of discomfort
Projects
None yet
Development

No branches or pull requests

1 participant