Skip to content

Commit 79911fb

Browse files
AurMariomp911de
authored andcommitted
Use HQL parser when Hibernate 5 is on the classpath.
Closes #3212
1 parent d13d5cd commit 79911fb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/QueryEnhancerFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @author Diego Krupitza
2626
* @author Greg Turnquist
2727
* @author Mark Paluch
28+
* @author Aurelien Marionneau
2829
* @since 2.7.0
2930
*/
3031
public final class QueryEnhancerFactory {
@@ -37,13 +38,16 @@ public final class QueryEnhancerFactory {
3738
private static final boolean hibernatePresent = ClassUtils.isPresent("org.hibernate.query.TypedParameterValue",
3839
QueryEnhancerFactory.class.getClassLoader());
3940

41+
private static final boolean hibernate5Present = ClassUtils.isPresent("org.hibernate.jpa.TypedParameterValue",
42+
QueryEnhancerFactory.class.getClassLoader());
43+
4044
static {
4145

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

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

73-
return hibernatePresent ? JpaQueryEnhancer.forHql(query) : JpaQueryEnhancer.forJpql(query);
77+
return (hibernatePresent || hibernate5Present) ? JpaQueryEnhancer.forHql(query) : JpaQueryEnhancer.forJpql(query);
7478
}
7579

7680
}

0 commit comments

Comments
 (0)