-->
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: EHCache 1.1 / Hibernate 2.1 Problem
PostPosted: Mon Aug 29, 2005 11:02 am 
Newbie

Joined: Mon Feb 28, 2005 12:53 pm
Posts: 18
Hello.

I want to use EHCache 1.1 with Hibernate 2.1.
I created the ehcache.xml file where I added the object I wanted to be cached :

<cache name="Test"
maxElementsInMemory="15000"
eternal="true"
overflowToDisk="true"
/>

In the Test.hbm.xml object file I added :

<cache usage="read-write" />

Also in hibernate.properties I have :

hibernate.cache.use_query_cache true
hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider

I also set an entry in my log4j.xml to have a ehcache.log file.

I want to get all Test objects (about 14000 elements) and add them to a JComboBox. Practically, I click a button and a new dialog which contains the combobox is displayed. I start my server and my client applications.
At first load on my combobox in ehcache.log file I have entries like following :

--------------------
key: 1
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.store.MemoryStore] Test: MemoryStore miss for 1
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.Cache] Test cache - Miss
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.hibernate.Plugin] Element for 1 is null
2005-08-29 17:35:51,031 DEBUG [net.sf.ehcache.Cache] Test: Is element with key 1 expired?: false
---------------------

At second load on my combobox (client is not closed) I have entries like :

---------------------
key: 1
2005-08-29 17:36:33,484 DEBUG [net.sf.ehcache.store.MemoryStore] Test: MemoryStore hit for 1
2005-08-29 17:36:33,484 DEBUG [net.sf.ehcache.Cache] Test: Is element with key 1 expired?: false
---------------------

So it seems the cache works, because all elements are marked with "hit" in the log for the second access. But the time for first and second loads are the same (about 20 seconds - the time is measured on the server for the method which gets all the objects from database).

Is there something I am missing? From the log I can see the cache is working, but from the loading times I can see it doesn't.
Please help me if you heard about such behaviour.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 4:06 am 
Newbie

Joined: Mon Feb 28, 2005 12:53 pm
Posts: 18
I had to to do the following :

criteria.setCacheable(true);
criteria.setCacheRegion(class.getName());

for the the class objects I wanted to be cached.
But I am dissapointed that the time obtained to get
the objects from cache is still a bit high (is three time faster
than to get the objects from database). I still feel that
something is missing.


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.