Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select Top 1 records from MS SQL using Spring Data JPA

I am using the below @Query annotation to get the first few record from MS-SQL. It's showing error saying "< operator > or AS expected..."

   @Query("SELECT Top 1 * FROM NEVS010_VEH_ACTV_COMMAND C WHERE C.EVS014_VIN = :vin ORDER BY C.EVS010_CREATE_S DESC")
    CommandStatus findCommandStatusByVinOrderByCreatedTimestampDesc(@Param("vin") String vin);
like image 557
Vijai Avatar asked Jul 25 '18 17:07

Vijai


1 Answers

You can also use findFirst and findTop as mentioned in the Docs:

findFirstByVinOrderByCreatedTimestampDesc(String vin)
like image 177
chubock Avatar answered Oct 02 '22 12:10

chubock