google/sqlcommenter

Cannot see any comments in the logs when using Java with Spring Boot and Hibernate

johanhaleby opened this issue · 0 comments

Hi,

I'm experimenting with SQL Commenter for Java (using version 2.0.1). We're using Spring Boot 2.7.0 and Hibernate (the version that ships with spring boot) and I've followed the instructions here. I.e. I've added:

@Configuration
MyConfigurer implements WebMvcConfigurer {
	
   @Bean
    public SpringSQLCommenterInterceptor sqlInterceptor() {
         return new SpringSQLCommenterInterceptor();
    }
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(sqlInterceptor());
    }
  
}

and added

properties.setProperty("hibernate.session_factory.statement_inspector", SCHibernate.class.getName());

to our Hibernate configuration.

Then I've started MySQL (5.6) in Docker and enabled logging:

 SET GLOBAL general_log = 'ON';

If I run SHOW VARIABLES LIKE "general_log%"; I see this:

+------------------+---------------------------------+
| Variable_name    | Value                           |
+------------------+---------------------------------+
| general_log      | ON                              |
| general_log_file | /var/lib/mysql/fb28ada36c57.log |
+------------------+---------------------------------+

When I log into the container and tail the log I see a lot SQL queries but I don't see any comments that I expect to see with sql-commenter.

What am I doing wrong?