-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: EntityLoader misses to use Filter after L2 cache eviction.
PostPosted: Thu Jul 15, 2010 7:00 am 
Newbie

Joined: Thu Jul 15, 2010 6:44 am
Posts: 13
Dear All,

I'm facing a peculiar issue with my read only app, which uses Hibernate 3.5.3 and JbossCache-3.2.5.

All the entities in my data model are versioned and have logical deletion using a field "endDate" so when ever a version is incremented the pervious version is not deleted but end dated.

I fetch the latest version using a filter with clause "endDate is null".

All my entities are to be cached as Immutable & with cache usage "read-only". This all works fine, till I try to evict a entity.

I'm using following hibernate config.

Code:

...
.....
<property name="connection.datasource">java:SybaseDB</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="generate_statistics">true</property>
<property name="cache.provider_class">org.hibernate.cache.jbc.JBossCacheRegionFactory</property>

<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_minimal_puts">true</property>
<property name="cache.use_structured_entries">true</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.region.factory_class">org.hibernate.cache.jbc.JndiMultiplexedJBossCacheRegionFactory</property>
<property name="cache.region.jbc2.cachefactory">java:CacheManager</property>
<property name="cache.region.jbc2.cfg.entity">mvcc-entity</property>
<property name="cache.region.jbc2.cfg.collection">mvcc-entity</property>
<property name="cache.region.jbc2.cfg.query">local-query</property>      

...
.....



There is another application which updates my database, so I need to refresh the cache for a few entity ocassionally.

I'm using the Cache.evictXXX() API to evict the entities/collections I want to reload from database.

However, after eviction on subsequent request to get the entity, the core doesnt apply the filter and fires a sql which just uses the unique key and doesnt append the "endDate is null" condition which is enabled for the session. Due to which the sql fetches multiple rows and throws an exception causing the app to fail loading the requested entity.

And I have to restart the app, to get it working again.

Can any one point me to the right direction to what is that I'm doing wrong over here?

Thanks.

_________________
Vikram.
Http://enterprisejava4u.blogspot.com


Top
 Profile  
 
 Post subject: Re: EntityLoader misses to use Filter after L2 cache eviction.
PostPosted: Thu Jul 15, 2010 7:50 am 
Newbie

Joined: Thu Jul 15, 2010 6:44 am
Posts: 13
Investigating further found that this was happening for collections that where cached in L2 cache (jboss-cache).

Not caching those collections resolves the issue.

The loading of collections from the l2 cache, doesnt respect the clause of the enabled filter which causes multiple rows to be loaded for the same entity as the data is versioned...

Not having the collections cached; will cause my read-only app to degrade the response time as everytime I will have to fetch those rows from database...

_________________
Vikram.
Http://enterprisejava4u.blogspot.com


Top
 Profile  
 
 Post subject: Re: EntityLoader misses to use Filter after L2 cache eviction.
PostPosted: Sat Jul 17, 2010 10:59 am 
Newbie

Joined: Thu Jul 15, 2010 6:44 am
Posts: 13
I am planning to resolve this issue by creating two set of virtual entities using the "entity-name" attribute at class tag in hibernate mapping.

This way I would be able to use one set without filters with hard coded where clause which would provide me a similar feature as that of filter. This way I would also be able to cache the dataset without any issues.

The other set of same entities I would apply filters as need a dynamic condition but without cache.

Members may please comment if there is a better option available.

_________________
Vikram.
Http://enterprisejava4u.blogspot.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.