-->
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.  [ 1 post ] 
Author Message
 Post subject: Invalidation of 2nd level Cache
PostPosted: Fri Sep 24, 2004 6:08 am 
Newbie

Joined: Fri Aug 20, 2004 10:07 am
Posts: 9
Location: Sweden
I have multiple classes that are mapped to the same table and I suspect that this will cause problems for the 2nd level cache.
As I understand it (please correct me if I am wrong) there is one cache per rootclass and flushing an object will only invalidate the entry in it's own cache regardless of to which table it is mapped.
The problem for us is that even after updating an object of type "BusinessObject", reading an "DTO" (se mapping below) will return stale data from the cache because
flushing an "BusinessObject" will never invalidate an "DTO" even if they are mapped to the same table and have the same primary key.

One possible solution I have thought of is to keep track of which entities are mapped to the same table and use a preFlush-callback in an Interceptor to call SessionFactory.evict() on
all entities mapped to the same table. Of course this would probably not implement correct transactional behaviour (we use READ_COMITTED) but we might be able to live with that.

Do you see any problem with this approach?
Does it matter if I set the "mutable" attribute to true on the "DTO" class?

Backround: only one of the classes mapped to each table is mutable, the rest are DTOs that only contain parts of the properties. For performance reasons we don't want to read the BOs from the database and then copy data to DTO but rather read the DTOs directly from database, or in this case cache.


Hibernate version:
2.1.4
Mapping documents:
Code:
  <class name="BusinessObject" table="T">
    <id name="Id" column="ID" type="int">
      <generator class="assigned" />
    </id>
    <property name="P1" .../>
    <property name="P2" .../>
    <property name="P3" .../>
    <property name="P4" .../>
    <property name="P5" .../>
  </class>
  <class name="DTO" table="T">
    <id name="Id" column="ID" type="int">
      <generator class="assigned" />
    </id>
    <property name="P1" .../>
    <property name="P4" .../>
  </class>


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

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.