Printing "raise notice" messages when invoking stored procedures with MyBatis 3?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Printing "raise notice" messages when invoking stored procedures with MyBatis 3?

Aaron

We’re using MyBatis to invoke PostGres stored procedures. For diagnostic purposes, our stored procedures use “RAISE NOTICE” statements. Is there a way to tell MyBatis to log these statements? Or alternatively, can we somehow add a post-execution hook to MyBatis where we can get a hold of the statement or result set it used, so that we can invoke ResultSet.getWarnings() ourselves?

 

Thanks,

-          Aaron

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Printing "raise notice" messages when invoking stored procedures with MyBatis 3?

Iwao AVE!
Hi Aaron,

Assuming that the statementType is CALLABLE, you can get the warnings with a plugin.

@Intercepts({
    @Signature(
      type = ResultSetHandler.class,
      method = "handleOutputParameters",
      args = { CallableStatement.class }) })
public class LogWarningsPlugin implements Interceptor {
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
    SQLWarning warnings = ((CallableStatement) invocation.getArgs()[0]).getWarnings();
    return invocation.proceed();
  }
 // ...
}

Regards,
Iwao


2017-09-29 0:17 GMT+09:00 Aaron Pieper <[hidden email]>:

We’re using MyBatis to invoke PostGres stored procedures. For diagnostic purposes, our stored procedures use “RAISE NOTICE” statements. Is there a way to tell MyBatis to log these statements? Or alternatively, can we somehow add a post-execution hook to MyBatis where we can get a hold of the statement or result set it used, so that we can invoke ResultSet.getWarnings() ourselves?

 

Thanks,

-          Aaron

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.