在我的项目中,我使用 Jboss AS 7.1 服务器、hibernate 3.5 和 java 1.7。对于缓存,我使用的是 infinispan 5.1.5(“Brahma”)。通过以下方式,我在 hibernate config xml 中配置缓存。
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.InfinispanRegionFactory</prop>
<prop key="hibernate.cache.infinispan.statistics">true</prop>
<prop key="hibernate.cache.infinispan.cfg">infinispan-config.xml</prop>
在我的 infinispan-config.xml
<default>
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="false"
syncCommitPhase="false"
cacheStopTimeout="30000"
use1PcForAutoCommitTransactions="false"
autoCommit="true"
lockingMode="OPTIMISTIC"
useSynchronization="false"
transactionMode="TRANSACTIONAL"
/>
<invocationBatching enabled="true" />
<loaders passivation="true" shared="true" preload="true">
<loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true"
ignoreModifications="false" purgeOnStartup="false">
<properties>
<property name="location" value="/tmp/infinispan"/>
</properties>
</loader>
</loaders>
</default>
我的问题:
- 如何缓存 java 类中使用的查询?
- 对于休眠的 hbm 文件,缓存文件夹是由 infinispan 创建的,但是在相应的文件夹中没有生成缓存文件,为什么?