【发布时间】:2014-02-23 14:02:29
【问题描述】:
我不确定这是一个真正的问题还是只是配置问题,但我可以在我的日志控制台上看到即使在缓存命中时休眠如何命中(或至少抛出select 查询)。
我已经检查过缓存在 Ehcache 监视器上是否正常工作,它会为某个请求注册 100% 的命中。但我总是在日志中看到查询。
所有实体都标注如下:
@Entity
@Cacheable
@Cache(usage = READ_WRITE)
@Table(name = "city")
//@NamedQuery(name = "city.findById", query = "from City where ID = :id")
public class City extends Audit implements Serializable {
我的 ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
dynamicConfig="true" monitoring="autodetect">
<!-- Location of persistent caches on disk -->
<diskStore path="java.io.tmpdir/MxlServiceLayer" />
<cacheManagerPeerListenerFactory
class="org.terracotta.ehcachedx.monitor.probe.ProbePeerListenerFactory"
properties="monitorAddress=localhost, monitorPort=9889, memoryMeasurement=true" />
<defaultCache eternal="false" maxElementsInMemory="1000"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="600" memoryStoreEvictionPolicy="LRU" statistics="true" />
<cache name="authToken" eternal="false" maxElementsInMemory="100"
overflowToDisk="false" diskPersistent="true" timeToIdleSeconds="0"
timeToLiveSeconds="31536000" memoryStoreEvictionPolicy="LRU"
statistics="true" />
</ehcache>
而我一遍又一遍地看到的……
休眠:选择 city0_.ID 作为 ID2_,city0_.CREATED 作为 CREATED2_, city0_.CREATOR 作为 CREATOR2_,city0_.MODIFIED 作为 MODIFIED2_, city0_.MODIFIER 作为 MODIFIER2_,city0_.NAME 作为 NAME2_,city0_.state_fk 作为 state7_2_ 从城市 city0_ where State_fk=?
hibernate 真的会影响数据库吗?谁能给我解释一下,好吗?
我正在使用:
Spring Data JPA 1.2.0 中的 JPA 2.0
Ehcache 2.6.0
春季 3.2.1
【问题讨论】:
标签: java spring hibernate jpa ehcache