Skip to content

Commit

Permalink
Detect Hibernate 5 for HQL Parser support
Browse files Browse the repository at this point in the history
  • Loading branch information
AurMario authored Oct 26, 2023
1 parent d13d5cd commit ea503ae
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,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 +73,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 ea503ae

Please sign in to comment.