Last active
June 9, 2016 04:06
-
-
Save thjanssen/d00e6ecd621f2dd75648ae550505fa9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" | |
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> | |
<persistence-unit name="my-persistence-unit"> | |
... | |
<properties> | |
... | |
<!-- configure caching --> | |
<property name="hibernate.cache.use_query_cache" value="true"/> | |
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/> | |
</properties> | |
</persistence-unit> | |
</persistence> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Session s = (Session) em.getDelegate(); | |
Query q = s.createQuery("SELECT a FROM Author a WHERE id = :id"); | |
q.setParameter("id", 1L); | |
q.setCacheable(true); | |
log.info(q.uniqueResult()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment