## sqlcommenter-java
- [Introduction](#introduction)
- [Integrations](#integrations)
- [ORMs](#orms)
- [Frameworks](#frameworks)
- [Using them](#using-them)
- [Spring](#spring)
- [In XML Configuration](#in-xml-configuration)
- [In your Java source code](#in-your-java-source-code)
- [Hibernate](#hibernate)
- [Spring Hibernate](#spring-hibernate)
### Introduction
Provides integrations to correlate user source code from various
web frameworks with SQL comments from various ORMs.
When results are examined in SQL database logs, they'll look like this:
```shell
SELECT * from USERS /*action='run+this+%26+that',
controller='foo%3BDROP+TABLE+BAR',framework='spring,
traceparent='00-9a4589fe88dd0fc911ff2233ffee7899-11fa8b00dd11eeff-01',
tracestate='rojo%253D00f067aa0ba902b7%2Ccongo%253Dt61rcWkgMzE''*/
```
### Integrations
#### ORMs
- [X] Hibernate
- [ ] JDBC
#### Frameworks
- [X] Spring
- [ ] Jetty
- [ ] Netty
- [ ] Apache Tomcat
- [ ] gRPC
### Using it
#### Spring
##### Java-based configuration
If your're using Spring 5, then you can add the `SpringSQLCommenterInterceptor` as follows:
```java
import com.google.cloud.sqlcommenter.interceptors.SpringSQLCommenterInterceptor;
@EnableWebMvc
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
public SpringSQLCommenterInterceptor sqlInterceptor() {
return new SpringSQLCommenterInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(sqlInterceptor());
}
}
```
If you're using an older version of Spring, then your `WebConfig` class needs to extend the `WebMvcConfigureAdapter`
class instead:
```java
import com.google.cloud.sqlcommenter.interceptors.SpringSQLCommenterInterceptor;
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigureAdapter {
@Bean
public SpringSQLCommenterInterceptor sqlInterceptor() {
return new SpringSQLCommenterInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(sqlInterceptor());
}
}
```
##### XML-based configuration
You can also add the interceptor as a bean in your XML configuration:
```xml