Hi all!
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!