This is my hypothetical Entity class,
@Entity
@NoArgsConstructor
@Data
public class Point{
@Id
@GeneratedValue
private Long id;
private double x;
private double y;
}
In the PointRepository, I want to have a method like this,
List<Point> findAllOrderByDistanceFromPointAsc (double a, double b);
Where the distance logic can be something like,
double distance = Math.sqrt( Math.pow((a-x), 2) + Math.pow((b-y), 2) )
So basically, it's a calculation between two columns and two passed parameter values. I understand it might be achievable by something like CriteriaQuery or Specification or writing custom native query, but I don't quite have the sufficient knowledge about how to exactly achieve that. Although ideally I would like to be achieve that without writing native query.