tags:

views:

124

answers:

2

hi, how to limit the number of results from database when I don't care about the other?

select e from Entity e /* just ten results, howto? */
A: 

You can try like this giving 10 results to be fetched explicitly.

entityManager.createQuery(SQL_QUERY).setParameter(arg0,arg1).setMaxResults(10).getResultList();

It will automatically create native query in back-end to retrieve specific number of results.

Nayan Wadekar
A: 

Is there a way to limit the number of results in a delete?

delete from Entity e /* just ten results, howto? */

In case you're wondering why anyone would do this, the use case is deleting non-essential rows to free up some space.

Daniel Winterstein