@Formula with Sort

I have tow fields for 1st name and last name, I use formula to concat them. Im using Pageable to sort the results, but I cant sort with the Formula field.
Observation

  • When no colum name is specified the the concat is named as formula1
  • when name is specified as ‘as’ in query fragment the name of concat is also formula1
  • when colum name is specified the name in query is created as a combination of entity class name
    and field name in camal case

when I use the generated name it throws PropertyReferenceException
does anyone know how to handle this situation properly

Please share your model, repository, usage and the generated SQL with us, otherwise it’s hard to understand what is going on. Spring Data usually works on the domain/entity level, so whatever you name the property/field in your entity that uses @Formula, you will have to use that name for the Sort.

Thanks for the replay. I looked into the issue more and figured it out, its was a mistake on my side.

if I dont specify colum name it will be mapped to the field name, and i can use the field name for sorting