Select top 1 result using JPA

后端 未结 4 1317
孤独总比滥情好
孤独总比滥情好 2020-12-03 00:49

I need to bring from DB only one single result. How can I do that with JPA?

Select top 1 * from table

I tried

\"sel

4条回答
  •  被撕碎了的回忆
    2020-12-03 01:11

    Use a native SQL query by specifying a @NamedNativeQuery annotation on the entity class, or by using the EntityManager.createNativeQuery method. You will need to specify the type of the ResultSet using an appropriate class, or use a ResultSet mapping.

提交回复
热议问题