-->
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: Cache on root class only
PostPosted: Mon Nov 07, 2005 6:53 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Hibernate version: 3.1

What's the reason behind allowing cache only on root class binding?

Code:
      if ( persistentClass instanceof RootClass ) {
         RootClass rootClass = (RootClass) persistentClass;
         rootClass.setMutable( mutable );
         rootClass.setExplicitPolymorphism( isExplicitPolymorphism( polymorphismType ) );
         if ( StringHelper.isNotEmpty( where ) ) rootClass.setWhere( where );
         if ( cacheConcurrentStrategy != null ) {
            rootClass.setCacheConcurrencyStrategy( cacheConcurrentStrategy );
            rootClass.setCacheRegionName( cacheRegion );
            rootClass.setLazyPropertiesCacheable( cacheLazyProperty );
         }
      }


Rgds, Ales

_________________
--------------------------------
Ales Justin
JBoss, a division of Red Hat


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 8:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It doesn't make sense to cache only a subclass, they all share the same id scope

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:05 pm 
Newbie

Joined: Wed Jan 19, 2005 5:12 pm
Posts: 1
Location: Atlanta, GA
I have to disagree here. I've come across this issue a number of times and haven't been able to solve it elegantly.

Here is a class hierarchy, mapped using joined-subclass:

Code:
public class Person {
    List<PhoneNumber> phoneNumbers;
    List<PostalAddress> postalAddresses;
    String firstName;
    String lastName
    ...
}

public class User extends Person {
    String username;
    String password;
    Date lastLoginTimestamp;
    Date passwordExpirationTimestamp;
    ...
}


A lot of systems I have written require address book functionality. As such, an address book has a collection of Person objects.

During runtime though, I want to cache all Users for efficient access, not all Persons. There could be orders of magnitude more Person objects than Users (since people in an address book don't need to be a user, and most arent).

I only want to cache Users for efficient access, not all Persons, which, due to pure quantity, would force cache cleanup/maintenance too often.

I have many more concrete reasons why its convenient to cache instances of only a subclass, and not all instances in a class hierarchy.

Is this not reason enough to enable the <cache> element within <subclass> and <joined-subclass> mappings?


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.