Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-data fails when #{#entityName} SpEL is using in countQuery definition [DATAJPA-1163] #1500

Closed
spring-projects-issues opened this issue Aug 11, 2017 · 1 comment
Assignees
Labels
in: core type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Aug 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:

@Query(
    value = " select me.name from #{#entityName} me ",
    countQuery = " select count(me.id) from MyEntity me "
)
Page<String> findAllNames(final Pageable pageable);

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(final Pageable pageable);

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?

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)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jul 21, 2018

Maksim Kostromin commented

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants