Suppose you have the following Entity:
@Entity
public class Game {
@Id
@GeneratedValue
private Integer id;
private String name;
privat
Use annotation @Formula
Example: tickePrice = totalAmount / admissions
@Entity
public class Event {
...
// To avoid division by 0, and setting to 0 if admissions is 0
@Formula(value = "coalesce(totalAmount / NULLIF(admissions, 0), 0)")
private Double ticketPrice;
}
To sort by this column is required to be present as a column result.
GET example-url?size=25&page=0&sort=ticketPrice,ASC