I am using Spring Data REST and I have the following entity in my project.
@Data
@Entity
public class Loan{
@Id
@GeneratedValue
private Long id;
@JsonIgnore
private Long createdDate;
private Long amount;
private Long repaymentStartDate;
}
Now I want to sort the loans by the createdDate which will be automatically filled and JSONIgnored to prevent it from being updated. But I am unable to sort the loans by the createdDate when I call the endpoint loans?sort=createdDate.
How do I fix this?
Here is my repository:
public interface LoanRepository extends PagingAndSortingRepository<Loan, Long>{
}