Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Enabled hibernate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ziccardi committed Sep 11, 2017
1 parent 0e8e353 commit d30c2fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ public void setEntityManager(EntityManager entityManager) {


protected TypedQuery<T> createQuery(String jpql) {
return entityManager.createQuery(jpql, getType());
return entityManager.createQuery(jpql, getType()).setHint("org.hibernate.cacheable", true);
}

protected Query createUntypedQuery(String jpql) {
return entityManager.createQuery(jpql);
}

protected <O> TypedQuery<O> createQuery(String jpql, Class<O> type) {
return entityManager.createQuery(jpql, type);
return entityManager.createQuery(jpql, type).setHint("org.hibernate.cacheable", true);
}

protected org.hibernate.Query createHibernateQuery(String hql) {
Session session = (Session) entityManager.getDelegate();
return session.createQuery(hql);
return session.createQuery(hql).setCacheable(true);
}

//because you can't do T.class
Expand Down
7 changes: 7 additions & 0 deletions model/jpa/src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<jta-data-source>java:jboss/datasources/UnifiedPushDS</jta-data-source>

<mapping-file>META-INF/orm.xml</mapping-file>
<shared-cache-mode>ALL</shared-cache-mode>

<properties>
<property name="hibernate.dialect_resolvers" value="org.jboss.aerogear.unifiedpush.jpa.MysqlDialectResolver"/>
Expand All @@ -31,7 +32,13 @@
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.transaction.flush_before_completion" value="true"/>
<property name="hibernate.id.new_generator_mappings" value="true"/>

<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>

<property name="hibernate.cache.infinispan.statistics" value="true"/>
</properties>

</persistence-unit>

</persistence>

0 comments on commit d30c2fc

Please sign in to comment.