-->
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: Hibernate Search and Ehcache
PostPosted: Wed Sep 07, 2011 11:23 am 
Newbie

Joined: Mon Nov 28, 2005 12:32 pm
Posts: 3
Relevant Environment

Hibernate Search v3.4.1
Hibernate Core v3.6.7
EHcahce v2.4.1

Solution I am trying to achieve is to back Lucene indexes via the ehcache and i was given to understand from reading the documentation here (http://relation.to/18621.lace) that you can specify to fetch the entities from the second level cache before extracting the same from the DB.

In our Search API I have the following
Code:
      FullTextQuery fullTextQuery = buildQuery(filterParameters, false);
      
      fullTextQuery.initializeObjectsWith(ObjectLookupMethod.SECOND_LEVEL_CACHE, DatabaseRetrievalMethod.QUERY);
      List<Object> results = new ArrayList<Object>();
      Iterator<?> iterator = fullTextQuery.iterate();
      
      while (iterator.hasNext()) {
         Object element = iterator.next();
         results.add(element);
      }

While this does not break anything and search results behave and come back like we expect We get no In Memory Hits for the second level cache. I have verified this by observing the real time cache statistics via jconsole.

So we have
Entities in Second Level Cache (memory)
Projected attributes of the Entities in Index (directory)

but I am missing something since it never seems to extract the entities that resulted in the hits from the second level cache.

Any ideas or am I missing something obvious? Should this be even possible?

Thanks in advance
-a


Top
 Profile  
 
 Post subject: Re: Hibernate Search and Ehcache
PostPosted: Wed Sep 07, 2011 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Any ideas or am I missing something obvious? Should this be even possible?

Yes this should be possible.

Did you enable second level caching for these entities ?
Does it work when doing a simple load ?
Did you enable Hibernate statistics ?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hibernate Search and Ehcache
PostPosted: Wed Sep 07, 2011 2:54 pm 
Newbie

Joined: Mon Nov 28, 2005 12:32 pm
Posts: 3
Code:
<property name="jpaPropertyMap">
         <props>
            <!-- <prop key="hibernate.show_sql">true</prop> -->
            <!-- <prop key="hibernate.format_sql">true</prop> -->
            <!-- Cache-->
            <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use.second.level.cache}</prop>
            <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use.query.cache}</prop>
            <prop key="hibernate.generate_statistics">${hibernate.cache.generate.statistics}</prop>
            <prop key="hibernate.cache.use_structured_entries">${hibernate.cache.use.structured.entries}</prop>
            <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</prop>
            <prop key="hibernate.cache.provider_configuration_file_resource_path">/ehcache/ehcache.xml</prop>
      


is a snippet of the cache settings in the dbmsContext where all the properties are set to true so
Quote:
Did you enable second level caching for these entities ?

Yes via the ehcache.xml and correspondingly via the
Code:
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
annotation for the domain object
In looking @ jconsole cache statistics I see the ObjectStoreMemmoryCount go up so I know these are being cached

Does it work when doing a simple load ?
I have not tried this yet since all of our results or catalog page get driven by executing against the search service, but I will write a simple load and see what I get

Did you enable Hibernate statistics ?
I am assuming you mean "hibernate.generate_statistics" and that has been set to true as in point 1.


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.