-->
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.  [ 2 posts ] 
Author Message
 Post subject: "mutable" attribute ignored when using 2ndLevelCac
PostPosted: Fri Aug 31, 2007 7:56 am 
Newbie

Joined: Wed Jan 17, 2007 11:50 am
Posts: 10
Hello,

many entities in my application are read-only, so I use the mutable="false" setting in their mapping files. This causes Hibernate to set their status to read-only and omit the snapshot creation (TwoPhaseLoad, lines 172-178).

This read-only status in turn optimizes flushing performance since the PersistenceContext's "hasNonReadOnlyEntities" flag is false when only read-only entities are in a session, causing flushing attempts to abort immediately.

However, when I turn on the second-level-cache for an immutable entity type, the entry status is not restored to read-only when an instance is assembled from the second-level-cache:

DefaultLoadEventListener, method assembleCacheEntry, lines 566+:
Code:
persistenceContext.addEntry(
   result,
   Status.MANAGED,
   values,
   null,
   id,
   version,
   LockMode.NONE,
   true,
   subclassPersister,
   false,
   entry.areLazyPropertiesUnfetched()
);


The Status is always set to MANAGED which causes the PersistenceContext's hasNonReadOnlyEntities to switch to true, which causes a severe hit in flushing performance when the session is large and contains only read-only entities.

This behaviour could probably be fixed by changing Status.MANAGED in the above code to:

persister.isMutable() ? Status.MANAGED : Status.READ_ONLY

This would be consistent with the the code in TwoPhaseLoad.

Any comments?


Last edited by cbrehm on Tue Sep 18, 2007 3:45 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 7:17 am 
Newbie

Joined: Wed Jan 17, 2007 11:50 am
Posts: 10
I still haven't resolved this issue. The suggested code fix seems to work, but I'd really appreciate if any Hibernate developer could take a look at this and comment whether this is actually a bug in Hibernate and if my fix is ok.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.