spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
905 stars 558 forks source link

Does spring data rest supports sorting on inherited fields? #2363

Closed prasannabalaraman closed 4 months ago

prasannabalaraman commented 4 months ago

My entity class extends an audit class with audit fields (createdDate, createdBy, modifiedDate, modifiedBy). My repo extends PagingAndSortingRepository. Sorting is not working if I use any of the audit fields but it works if I pass any of the fields in the entity class.

I am using spring data rest 2.7.12.

{{baseUrl}}/{{apiVersion}}/{{apiContext}}/apps?sort=createdDate,desc&size=50

I also noticed "order by" in the generated sql for the entity class fields but not for the audit class fields.

Appreciate your help.

prasannabalaraman commented 4 months ago

After further analysis I figured out that I had @JsonIgnore on those audit fields. That was the reason it did not work. I removed it and it is working now. This issue can be closed.