I need help to perform the following SQL query in a JPA query, or some way to get the last record in Oracle with JPA.
SELECT * FROM (SELECT * FROM OAJ_COMITE ORDER BY ROWNUM DESC ) WHERE ROWNUM=1;
Oracle docs says "Without an order_by_clause, no guarantee exists that the same query executed more than once will retrieve rows in the same order.", so your internal query does not have any sence.
So if you want to get last line by some criteria, you should use form like
select * from table order by field desc fetch first row only, where field desc is your sort parameters.
select * from table order by field desc fetch first row only
BTW, I'm not sure it's possible to convert query like this to JPA, because there are used Oracle-specific constructions. So you'll need to use 'native query', not JPA.