setCacheable « Query « JPA Q&A

1. Speed your queries with setCacheable(true)

Hi there, a common problem of low performance are repeated queries which give the same result each time. For example: Query q = session .createQuery("from artikel in class Artikel where lower(artikel.isbn) = ?"); q.setString(0,_isbn); ... return artikel.getId(); Insted of repeating the same query every time an getting the same result from database, you can simply cache it. Do not forget to ...

2. How setCacheable of Query will work