I am new to spring JPA. I have one query, so I have to get a result set and take only the line at the top. I do not know how to do this in spring JPA. And I don't want this to be done using the @Query annotation, since I was asked not to go with any queries inside the code. This is the uery I want to convert
My request
SELECT id,name FROM example_table ORDER BY id DESC LIMIT 1;
I tried something like this in my predicate file:
public Predicate getLatest(){
QExampleTable example = QExampleTable.exampleTable;
return (Predicate) example.id.desc();
}
and this is what my jpa repository looks like:
public ExampleTable findOne(MyPredicate.getLatest());
But this does not work, and I know that it is not clear. But I seriously donβt know how to convert this above request. Can anyone help me with this
source
share