I need the max first record in the application, I'm working with Spring boot JPA and MYSQL query I have tried are,
@Query("select d from Table where d.StatusType=:StatusType and d.tableNumber< :cuurentTableNumber ORDER BY d.tableNumber DESC LIMIT 1",nativeQuery = true)
Draw findTop1ByOrderByDrawNumberDesc(@Param("StatusType") Table.StatusType StatusType, @Param("tableNumber")int cuurentTableNumber);
@Query("select d from Table d where d.StatusType=:StatusTypeand d.tableNumber<:cuurentTableNumber")
Draw findTop1ByOrderByDrawNumberDesc(@Param("StatusType") Table.StatusType StatusType, @Param("tableNumber")int cuurentTableNumber , Pageable pageable);
And other trials too, but nothing is working many times it gave me an error of multiple record found. And I need only one record which is Max but less than current number.
LIMIT does not work with JPA, so cant use that one.
Does anybody has any idea how to achieve this.