Skip to content

Commit

Permalink
Use HQL parser when Hibernate 5 is on the classpath.
Browse files Browse the repository at this point in the history
Closes #3212
  • Loading branch information
AurMario authored and mp911de committed Nov 2, 2023
1 parent d13d5cd commit 79911fb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @author Diego Krupitza
* @author Greg Turnquist
* @author Mark Paluch
* @author Aurelien Marionneau
* @since 2.7.0
*/
public final class QueryEnhancerFactory {
Expand All @@ -37,13 +38,16 @@ public final class QueryEnhancerFactory {
private static final boolean hibernatePresent = ClassUtils.isPresent("org.hibernate.query.TypedParameterValue",
QueryEnhancerFactory.class.getClassLoader());

private static final boolean hibernate5Present = ClassUtils.isPresent("org.hibernate.jpa.TypedParameterValue",
QueryEnhancerFactory.class.getClassLoader());

static {

if (jSqlParserPresent) {
LOG.info("JSqlParser is in classpath; If applicable, JSqlParser will be used");
}

if (hibernatePresent) {
if (hibernatePresent || hibernate5Present) {
LOG.info("Hibernate is in classpath; If applicable, HQL parser will be used.");
}
}
Expand All @@ -70,7 +74,7 @@ public static QueryEnhancer forQuery(DeclaredQuery query) {
return new DefaultQueryEnhancer(query);
}

return hibernatePresent ? JpaQueryEnhancer.forHql(query) : JpaQueryEnhancer.forJpql(query);
return (hibernatePresent || hibernate5Present) ? JpaQueryEnhancer.forHql(query) : JpaQueryEnhancer.forJpql(query);
}

}

0 comments on commit 79911fb

Please sign in to comment.