Enabling Query Caching with CriteriaQuery. Is it possible?

I want to enable hibernate cache. I understand that "Query" and "Criteria" have a "setCachable" function to mark the query as cacheable. Is there a way to do this with "CriteriaQuery"?

    CriteriaQuery<UserEntity> criteria = entityManager.getCriteriaBuilder().createQuery(UserEntity.class);
    Root <UserEntity> contactRoot = criteria.from(UserEntity.class);
    criteria.select(contactRoot);

    Predicate predicate = entityManager.getCriteriaBuilder().equal(
            contactRoot.get("username"), username);
    criteria.where(predicate);

    UserEntity contact = entityManager.createQuery(criteria).getSingleResult();

    return contact;

      

+3
hibernate query-cache


source to share


No one has answered this question yet

Check out similar questions:

996
What are the possible Hibernate hbm2ddl.auto config values ​​and what do they do
37
Hibernating the L2 cache in a Grails application
nine
Hibernate cache - for objects not in L2 cache - risky? useful? bad practice?
4
Hibernate caching and lazy loaded associations
3
automatic invalidation of the request cache
1
How does Hibernate know which query cache to use?
1
Mutable objects in the Hibernate cache
1
Hibernate Cache always skips
1
Hibernate criteria examples not working with query cache?
0
Hibernate Query cache not returning newly added entity



All Articles
Loading...
X
Show
Funny
Dev
Pics