开发者

JBoss Cache Configuration

I'm using an extended persistence context (injected Entitymanager at SFSB) and have additionally set @TransactionManagement(value=TransactionManagementType.BEAN) for the SFSB to have full control over the UserTransaction.

The Transaction is controlled on client side where I start a lookup for the SFSBs containing a reference to the entity beans.

SymbolischeWerte sbw = (SymbolischeWerte)symbolischeWerteHome.findByPrimaryKey(BigDecimal.valueOf(24704578762l));
System.out.println(symbolischeWerteHome.getSEQ_ID() + "\t\t" + symbolischeWerteHome.getName());
symbolischeWerteHome.beginTransaction();
symbolischeWerteHome.setName(symbolischeWerteHome.getName().concat("A"));
symbolischeWerteHome.commitTransaction();

that works so far!

After enabling JBoss Cache and multiple clients, only the first client causes a database select. The others get the entity from cache.

perfect!

The problem:

2 clients (CLIENTA, CLIENTB) concurrently looks up for an entity with the same primary key, while CLIENTA runs through the program, CLIENTB is manually halt after findByPrimaryKey. When CLIENTA has finished (value is successfully persisted) CLIENTB's system out shows the old value which is modified and stored into database too.

So I'm loosing CLIENTA's values!!

Is this a JBoss Cache configuration problem or is this a general problem of my systems design?

Cache config for entity:

@Cache(usage=CacheConcurrencyStrategy.TRANSACTIONAL, region="com.culturall.pension.system.SymbolischeWerteEntity")

Cache config in persistence.xml

<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory开发者_高级运维"/>
<property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>
<property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>
<property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/>

Thx for ANY advice!


If I read you right, you configured the cache to be transactional. This by definition means clients in different transactions see different versions of data; if the data was modified in other transaction, you need to refresh the data from DB explicitely (thus discarding your changes) to see those changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜