-->
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: Cache a list of code
PostPosted: Fri Jun 24, 2005 11:22 pm 
Regular
Regular

Joined: Thu Dec 02, 2004 10:42 am
Posts: 54
I have a table containing a set of record, which is the available country code. They are used for populating the Web's dropdown list.

It will be common to cache all the available country code. But with the 2 common method to read those code out, they cannot be cached:

1. IList codeList = session.CreateCriteria(typeof(CountryCode)).List();
2. IList codeList = session.Find("from CountryCode");

Either method is using SessionImpl.Find() in the end, which connect to DB and fetch the data from it every time, it cannot read from cache as we all know.

The only way I found is, creating a new table with object class "CodeType", which has children map to the "ChildrenCodeTable". One of the instance map to "CountryCode" table. Everytime I use session.Load() to load the "Parent" CodeType code, which in turn will load all the children, which loaded from the cache after the 1st time loading.

Similar method would be cache all the CountryCode IDs by myself, and use session.Load() to load each of the CountryCode when needed.

These methods seem redundant and complicated (extra table/records or I need to handle my own cache/expire/Evict), but I cannot find any other way.

Please help!


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.