diff --git a/pom.xml b/pom.xml
index 0bc96784c3..2f9074a69d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
pom
Spring Data JPA Parent
@@ -31,6 +31,7 @@
3.0.3
6.2.1.Final
2.7.1
+
2.1.214
4.5
8.0.31
42.5.0
diff --git a/spring-data-envers/pom.xml b/spring-data-envers/pom.xml
index 0c3d16ef85..8a371e0649 100755
--- a/spring-data-envers/pom.xml
+++ b/spring-data-envers/pom.xml
@@ -5,12 +5,12 @@
org.springframework.data
spring-data-envers
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
org.springframework.data
spring-data-jpa-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
../pom.xml
diff --git a/spring-data-jpa-distribution/pom.xml b/spring-data-jpa-distribution/pom.xml
index 991cd8cbf0..068a03a67b 100644
--- a/spring-data-jpa-distribution/pom.xml
+++ b/spring-data-jpa-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
../pom.xml
diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml
index 248ac4b2fd..436db40431 100644
--- a/spring-data-jpa/pom.xml
+++ b/spring-data-jpa/pom.xml
@@ -6,7 +6,7 @@
org.springframework.data
spring-data-jpa
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
Spring Data JPA
Spring Data module for JPA repositories.
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-jpa-parent
- 3.2.0-SNAPSHOT
+ 3.2.0-gh-2954-SNAPSHOT
../pom.xml
@@ -100,6 +100,13 @@
test
+
+ com.h2database
+ h2
+ ${h2}
+ test
+
+
com.mysql
diff --git a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Hql.g4 b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Hql.g4
index 488031b42c..b702bad0c1 100644
--- a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Hql.g4
+++ b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Hql.g4
@@ -579,7 +579,7 @@ dealingWithNullExpression
// https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#hql-like-predicate
stringPatternMatching
- : expression NOT? (LIKE | ILIKE) expression (ESCAPE character)?
+ : expression NOT? (LIKE | ILIKE) expression (ESCAPE (character|parameter))?
;
// https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#hql-elements-indices
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
index 39d6271fe3..17458b20e6 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java
@@ -2124,7 +2124,11 @@ public List visitStringPatternMatching(HqlParser.StringPat
if (ctx.ESCAPE() != null) {
tokens.add(new JpaQueryParsingToken(ctx.ESCAPE()));
- tokens.addAll(visit(ctx.character()));
+ if (ctx.character() != null) {
+ tokens.addAll(visit(ctx.character()));
+ } else if (ctx.parameter() != null) {
+ tokens.addAll(visit(ctx.parameter()));
+ }
}
return tokens;
diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java
index 0a148f145f..b5a41fe998 100644
--- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java
+++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java
@@ -1206,6 +1206,12 @@ public List visitLike_expression(JpqlParser.Like_expressio
tokens.add(new JpaQueryParsingToken(ctx.LIKE()));
tokens.addAll(visit(ctx.pattern_value()));
+ if (ctx.ESCAPE() != null) {
+
+ tokens.add(new JpaQueryParsingToken(ctx.ESCAPE()));
+ tokens.addAll(visit(ctx.escape_character()));
+ }
+
return tokens;
}
diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java
index 0caf735d4e..473331252a 100644
--- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java
+++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java
@@ -23,8 +23,9 @@
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477.
*
* @author Oliver Gierke
+ * @author Greg Turnquist
*/
-@ContextConfiguration("classpath:eclipselink.xml")
+@ContextConfiguration("classpath:eclipselink-h2.xml")
class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests {
@Disabled
@@ -34,4 +35,5 @@ void executesNotInQueryCorrectly() {}
@Disabled
@Override
void executesInKeywordForPageCorrectly() {}
+
}
diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java
index 6fa3e2b00f..4b6c4bb9eb 100644
--- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java
+++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java
@@ -25,7 +25,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,10 +52,11 @@
*
* @author Oliver Gierke
* @author Krzysztof Krason
+ * @author Greg Turnquist
* @see QueryLookupStrategy
*/
@ExtendWith(SpringExtension.class)
-@ContextConfiguration(locations = "classpath:config/namespace-application-context.xml")
+@ContextConfiguration(locations = "classpath:config/namespace-application-context-h2.xml")
@Transactional
class UserRepositoryFinderTests {
@@ -235,7 +235,6 @@ void parametersForContainsGetProperlyEscaped() {
.isEmpty();
}
- @Disabled("Can't get ESCAPE clause working with Hibernate")
@Test // DATAJPA-1519
void escapingInLikeSpels() {
@@ -246,7 +245,6 @@ void escapingInLikeSpels() {
assertThat(userRepository.findContainingEscaped("att_")).containsExactly(extra);
}
- @Disabled("Can't get ESCAPE clause working with Hibernate")
@Test // DATAJPA-1522
void escapingInLikeSpelsInThePresenceOfEscapeCharacters() {
@@ -256,7 +254,6 @@ void escapingInLikeSpelsInThePresenceOfEscapeCharacters() {
assertThat(userRepository.findContainingEscaped("att\\x")).containsExactly(withEscapeCharacter);
}
- @Disabled("Can't get ESCAPE clause working with Hibernate")
@Test // DATAJPA-1522
void escapingInLikeSpelsInThePresenceOfEscapedWildcards() {
@@ -288,8 +285,7 @@ void executesQueryWithProjectionContainingReferenceToPluralAttribute() {
List rolesAndFirstnameBy = userRepository.findRolesAndFirstnameBy();
- assertThat(rolesAndFirstnameBy)
- .isNotNull();
+ assertThat(rolesAndFirstnameBy).isNotNull();
for (RolesAndFirstname rolesAndFirstname : rolesAndFirstnameBy) {
assertThat(rolesAndFirstname.getFirstname()).isNotNull();
diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java
index 5eb7490398..821b119a73 100644
--- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java
+++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java
@@ -625,7 +625,7 @@ List findUsersByFirstnameForSpELExpressionWithParameterIndexOnlyWithEntity
List findByNamedQueryWithConstructorExpression();
// DATAJPA-1519
- @Query("select u from User u where u.lastname like '%?#{escape([0])}%' escape ?#{escapeCharacter()}")
+ @Query("select u from User u where u.lastname like %?#{escape([0])}% escape ?#{escapeCharacter()}")
List findContainingEscaped(String namePart);
// DATAJPA-1303
diff --git a/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml b/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml
new file mode 100644
index 0000000000..9cb3eab275
--- /dev/null
+++ b/spring-data-jpa/src/test/resources/config/namespace-application-context-h2.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-jpa/src/test/resources/eclipselink-h2.xml b/spring-data-jpa/src/test/resources/eclipselink-h2.xml
new file mode 100644
index 0000000000..71d4ab6372
--- /dev/null
+++ b/spring-data-jpa/src/test/resources/eclipselink-h2.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+ org.h2.Driver
+ jdbc:h2:mem:hades
+ sa
+
+ create-tables
+ false
+ SEVERE
+
+
+
diff --git a/spring-data-jpa/src/test/resources/infrastructure-h2.xml b/spring-data-jpa/src/test/resources/infrastructure-h2.xml
new file mode 100644
index 0000000000..723454c015
--- /dev/null
+++ b/spring-data-jpa/src/test/resources/infrastructure-h2.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-jpa/src/test/resources/scripts/h2-init.sql b/spring-data-jpa/src/test/resources/scripts/h2-init.sql
new file mode 100644
index 0000000000..1c8a0e7976
--- /dev/null
+++ b/spring-data-jpa/src/test/resources/scripts/h2-init.sql
@@ -0,0 +1 @@
+;
\ No newline at end of file
diff --git a/spring-data-jpa/src/test/resources/scripts/h2-stored-procedures.sql b/spring-data-jpa/src/test/resources/scripts/h2-stored-procedures.sql
new file mode 100644
index 0000000000..1023dc1a39
--- /dev/null
+++ b/spring-data-jpa/src/test/resources/scripts/h2-stored-procedures.sql
@@ -0,0 +1,9 @@
+/;
+DROP alias IF EXISTS plus1inout
+/;
+CREATE alias plus1inout AS $$
+Integer plus1inout(Integer arg) {
+ return arg + 1;
+}
+$$
+/;