Description
When JSqlParser is in classpath, the org.springframework.data.jpa.repository.query.QueryEnhancerFactory
enables org.springframework.data.jpa.repository.query.JSqlParserQueryEnhancer
.
However JSqlParser is quite CPU and memory allocation expensive, and it creates a new thread every time a query gets parsed.
Also, while the JSqlParser
is very useful for various use cases, it is not perfect, and can not parse all the queries. We have encountered even bugs, when parsing a more complex SQL, goes to endless loop.
One of our services reported 15% more CPU total, just from this component.
Essentially, we have JSqlParser in classpath for other reasons, but don't want all the negative effects from JSqlParserQueryEnhancer
.
Currently we disable it via byte-code manipulation:
new ByteBuddy()
.redefine(clazz)
.method(named("isJSqlParserInClassPath"))
.intercept(FixedValue.value(false))
.make()
.load(clazz.getClassLoader(), ClassReloadingStrategy.fromInstalledAgent());
However, it is not maintainable solution as we would most likely need to revisit this every time spring-data-jpa
gets upgraded.
Please provide another mechanism, preferably a Spring Boot property, to disable this mechanism.