-->
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: using EhCache with Hibenate?
PostPosted: Thu Jul 21, 2005 3:22 pm 
Newbie

Joined: Thu Jul 21, 2005 3:14 pm
Posts: 6
I am trying to use EHcache as second level cache with Hibernate. But I am getting into some questions, which are affecting my decision to use it. I have already enabled second level cache by including hibernate.cache.provider_class net.sf.hibernate.cache.EhCacheProvider property in Hibernate.prperties file. I have also included ehcache.xml and <cache> element in my mapping file.

I am giving snippet of code below that I am using to store user defined objects in second level cache.

Session session = sessionFactory.openSession;
Transaction tx = session.beginTransaction();
List xc = session.find("from sc.data.address");
tx.commit();
session.close();

This will put all the addresses from database to cache. Now suppose I want to retrieve back all of my objects back from cache, there is no method which can give me all my address objects back.
I am using following method to get list of all the keys.
List keyList = cache.getKeys();

This method gives you list of Keys of all the objects in Cache and then you have to loop through this list to get Element Object back and not address object back.

1. How can I get all of my address objects back from cache in one method call so that I can use them.
2. The object that you get back from cache by using cache.get(Key) is an Element object and not the object (address) that I put into cache.
3. DO I need to reconstruct my address object from Element object that I get back from Cache?

4. Are there any concrete examples where EHcache is being used as second level cache, where we are putting multiple database rows in cache and then getting all of them at once.

Can somebody please give me an urgent reply?

Thanks


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.