In Spring Data JPA 2.6.4 something changed in the alias detection that causes it to sometimes incorrectly determine the alias in a query that uses a cast().
For example:
from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt
incorrectly identifies the alias to be date when it should be u.
Oddly it doesn't pick up on some other similar uses of cast which it has no trouble with, e.g.
@Test
void detectAliasWithCastCorrectly() {
assertThat(detectAlias("from User u where (cast(:effective as date) is null) OR :effective >= u.createdAt")).isEqualTo("u");
assertThat(detectAlias("from User u where (cast(:effectiveDate as date) is null) OR :effectiveDate >= u.createdAt")).isEqualTo("u");
assertThat(detectAlias("from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt")).isEqualTo("u");
}
where only the last assertion fails. This is similar in some ways to 2232 although in my case it's with a JPA query rather than a native query.
In Spring Data JPA 2.6.4 something changed in the alias detection that causes it to sometimes incorrectly determine the alias in a query that uses a cast().
For example:
from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAtincorrectly identifies the alias to be
datewhen it should beu.Oddly it doesn't pick up on some other similar uses of cast which it has no trouble with, e.g.
where only the last assertion fails. This is similar in some ways to 2232 although in my case it's with a JPA query rather than a native query.