Skip to content

Instantly share code, notes, and snippets.

@sara4dev
Last active December 23, 2015 09:19
Show Gist options
  • Save sara4dev/6613568 to your computer and use it in GitHub Desktop.
Save sara4dev/6613568 to your computer and use it in GitHub Desktop.
import org.springframework.cache.annotation.Cacheable;
.
.
@Cacheable("longCache")
public List<Product> getAllProducts(final int pageNumber) {
System.out.println("Inside DAO so cache did not get used");
// TODO Auto-generated method stub
Query query = getEntityManager().createQuery("SELECT p FROM Product p");
return query.setFirstResult(pageNumber * PAGE_SIZE)
.setMaxResults(PAGE_SIZE).getResultList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment