I have a spring / springwebflow app (app A) that uses the Hibernate second level cache as well as the request cache. The application reads only from the database, not add / update / delete statements.
Requests are cached in one region called "daoCache". I installed this by annotation on namedQuerys
I have an annotated object from Hibernate @Cache with an attribute scope set to "daoCache" too
@Entity
@Table(name = "GROUP_OPERATOR")
@SequenceGenerator(name = "SEQ_GROUP_OPERATOR", sequenceName = "SEQ_GROUP_OPERATOR")
@NamedQueries( {
@NamedQuery(name = "findGroupOperatorByMaster", query = "FROM GroupOperator groupOperator WHERE groupOperator.segment IS NULL and groupOperator.pointsMaster.pointMaster like ?",
hints={@QueryHint(name="org.hibernate.cacheRegion", value="daoCache"),
@QueryHint(name="org.hibernate.cacheable", value="true")})
})
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "daoCache")
public class GroupOperator implements Serializable{
....
In addition, I have another application (app B) that connects to the same database and performs add / update / delete on the same database
20 , A. , , B, A 20 .
, , A "select * from group_operator, point_master = 1000". , , groupOperator # 1. ( 20 ), , №1. .
, B ( ), , * , *
, 20 A Operator # 1, . .
20 reset.
A ( " * group_operator, point_master = 1000" ). , 20 . , , B. ObjectNotFoundException. : groupOperator # 1
select , . , , ID 1 .
, ,
, ?
, , , , "daoCache", @Cache. "xxx.xxx.xxx.xx.groupOperator". , .
1- ? "daoCache" - beign, ? ?
2- ? , , , . .
ehcache.xml
<cache name="daoCache" maxElementsInMemory="30000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true">
</cache>
<cache name="rwCache" maxElementsInMemory="30000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true">
</cache>
<cache name="xxx.xxxx.xxx.xxxx.groupOperator" maxElementsInMemory="30000" eternal="false"
timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true">
</cache>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations
</artifactId>
<version>3.2.0.Final</version>
</dependency>
UPDATE:
hibernate.cache.region.factory_class. , . ,
. , , , - . , .
:...
, ,
( 20 ) ( , , select ). , , Entity . , Entity , , , , . , , , . , , .
, , . . , , ehcache.xml Entity.
<cache
name="com.citi.latam.business.services.dao.model.db.campaign.groupOperator"
maxElementsInMemory="30000" eternal="false" timeToIdleSeconds="120"
timeToLiveSeconds="120" overflowToDisk="true">
</cache>