if I'm using #entityName SpEL inside @Query.value all works fine with MyEntity in @Query.countQuery:
@Query(
value = " select me.name from #{#entityName} me ",
countQuery = " select count(me.id) from MyEntity me "
)
Page<String> findAllNames(finalPageablepageable);
but if I try use same #entityName SpEL inside @Query.countQuery, just like so:
@Query(
value = " select me.name from #{#entityName} me ",
countQuery = " select count(me.id) from #{#entityName} me "
)
Page<String> findAllNames(finalPageablepageable);
application fails:
...
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: unexpected char: '#' [ select count(me.id) from #{#entityName} me ]
...
Caused by: org.hibernate.QueryException: unexpected char: '#' [ select count(me.id) from #{#entityName} me ]
...
what the different betweel value and countQuery and why we can use same SpEL in both?
spring-projects-issues commentedAug 11, 2017
Maksim Kostromin opened DATAJPA-1163 and commented
see example here: https://github.com/daggerok/spring-data-spel-example/blob/master/app/src/main/java/daggerok/domain/MyEntityRepository.java
if I'm using #entityName SpEL inside
@Query
.value all works fine with MyEntity in@Query
.countQuery:but if I try use same #entityName SpEL inside
@Query
.countQuery, just like so:application fails:
what the different betweel value and countQuery and why we can use same SpEL in both?
links:
—
Regards,
Maksim
Affects: 1.11.6 (Ingalls SR6)
Reference URL: https://stackoverflow.com/questions/45579346/spring-data-jpa-spel-in-countquery-using-entityname-unexpected-char
Referenced from: pull request #283
Backported to: 2.0.9 (Kay SR9)
The text was updated successfully, but these errors were encountered: