-->
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: Caching lookup values on application startup
PostPosted: Fri May 21, 2004 2:27 pm 
Beginner
Beginner

Joined: Fri Apr 02, 2004 1:20 pm
Posts: 23
Our application uses lots of fine grained "lookup" type classes (i.e., BenefitStatus, Region, Frequency, ContractType).

The only way I can see of getting these into ehcache at application startup is to run queries for each ("from ContractType".list() ... etc). Is there a better way? Perhaps there should be a property in the mapping file?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 21, 2004 3:26 pm 
Beginner
Beginner

Joined: Fri Apr 02, 2004 1:20 pm
Posts: 23
Actually it doesn't seem worth complicating Hibernate's mapping file for the sake of such trivial code. This is what we are using (Criteria instead of Query to make sure the outer-join directives are used).

Code:
   private static void initialiseCache()
      throws HibernateException
   {
      Class[] cached = new Class[] {
         Lookup.class,
         Agent.class,
         BankBranch.class,
         BenefitType.class
      };
      
      for (int i = 0; i < cached.length; i++) {
         
         Criteria criteria = getSession().createCriteria(cached[i]);
         
         criteria.list();
      }
   }



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.