Skip to content

Commit ab34ee6

Browse files
committed
TYPE should be a valid attribute of an entity for a custom query.
See #3062, #3056.
1 parent 7627b23 commit ab34ee6

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4

+1
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ identification_variable
604604
| OUTER
605605
| FLOOR
606606
| SIGN
607+
| TYPE
607608
| VALUE)
608609
;
609610

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HqlQueryRendererTests.java

+7
Original file line numberDiff line numberDiff line change
@@ -1549,4 +1549,11 @@ void binaryLiteralsShouldWork() {
15491549
void escapeClauseShouldWork() {
15501550
assertQuery("select t.name from SomeDbo t where t.name LIKE :name escape '\\\\'");
15511551
}
1552+
1553+
@Test // GH-3062, GH-3056
1554+
void typeShouldBeAValidParameter() {
1555+
1556+
assertQuery("select e from Employee e where e.type = :_type");
1557+
assertQuery("select te from TestEntity te where te.type = :type");
1558+
}
15521559
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java

+7
Original file line numberDiff line numberDiff line change
@@ -941,4 +941,11 @@ void queryWithSignShouldWork() {
941941
void queryWithValueShouldWork() {
942942
assertQuery("select t.value from TestEntity t");
943943
}
944+
945+
@Test // GH-3062, GH-3056
946+
void typeShouldBeAValidParameter() {
947+
948+
assertQuery("select e from Employee e where e.type = :_type");
949+
assertQuery("select te from TestEntity te where te.type = :type");
950+
}
944951
}

0 commit comments

Comments
 (0)