-->
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: Second level cache DetachedCriteria
PostPosted: Sun Nov 16, 2008 1:59 pm 
Newbie

Joined: Sun Nov 16, 2008 1:10 pm
Posts: 2
I am working on performance improvement in my application. I add second level cache to some objects. I used Junit to see result of second level cache. I see, that when I am using function
Code:
getSession().createCriteria

everything seems to be ok. I can see that time to get next object is lower.
When I am using DetachedCriteria it seems that second level is off.
My config file looks like:
Code:
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.show_sql" >true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>
         


Query:
Code:
public List<ProcessDef> getAllProcessDef() throws Exception {
      DetachedCriteria criteria = DetachedCriteria.forClass(ProcessDef.class);
      getHibernateTemplate().setCacheQueries(true);
      return getHibernateTemplate().findByCriteria(criteria);
   }


Mapped object using annotation:
Code:
@Entity
@Table(name = "MNP_PROCESS_DEF", uniqueConstraints = { @UniqueConstraint(columnNames = { "NAME" }) })
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class ProcessDef {

   private Long id;
   private String name;

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "PROCESS_ID", nullable = false)
   public Long getId() {
      return id;
   }
   
     @Column(name = "NAME", nullable = false, length = 16)
   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public void setId(Long id) {
      this.id = id;
   }


And its corresponding ehcache configuration :
Code:
<cache name="ecrm.core.dao.db.model.process.ProcessDef"
        maxElementsInMemory="10"
        eternal="true"
        overflowToDisk="false"
        />

Any idea why my DeatechedCriteria does not work with secend level?


Top
 Profile  
 
 Post subject: Second level cache DetachedCriteria
PostPosted: Tue Nov 18, 2008 7:56 am 
Newbie

Joined: Sun Nov 16, 2008 1:10 pm
Posts: 2
Is it problem that Second Level Cache is not supporting DetachedCriteria? Have anyone some experience in this metter?


Top
 Profile  
 
 Post subject: Re: Second level cache DetachedCriteria
PostPosted: Wed May 20, 2009 4:32 am 
Newbie

Joined: Wed Nov 16, 2005 11:16 am
Posts: 1
Hello, Marieta!

I have absolutely same problem. Did you find any solution?


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.