We would like to get a hold of all the parameters that hibernate binds to SQL statments before they are sent to the sql server. Is that possible?
We’re using an Interceptor the get the SQL from Hibernate:
public class SQLInteceptor extends EmptyInterceptor {
@Override
public String onPrepareStatement(String sql) {
String prepared = super.onPrepareStatement(sql);
.....
}
}
But this gives the query without any parameters.
insert into Order (CreatedDate, sum) values (?, ?)
Hibernate shows the parameters if you turn logging on, so it’s in there somewhere
We’re are aware of different JDBC drivers that has this feature. But we’re not planning on replacing the JTDS drivers.
We had to use log4jdbc and do some hacking to the source code to achieve our goal. Not what we were looking for, but it works.