-->
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: When 2nd-level cache expired, it get very long time to load?
PostPosted: Mon Sep 22, 2008 10:48 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
Hibernate version:3.2.5

Mapping documents:
Code:
  <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
  <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
  <prop key="hibernate.cache.use_query_cache">true</prop>
 
  <prop key="hibernate.c3p0.min_size">10</prop>
  <prop key="hibernate.c3p0.max_size">35</prop>
  <prop key="hibernate.c3p0.acquire_increment">0</prop>
  <prop key="hibernate.c3p0.max_statements">0</prop>
  <prop key="hibernate.c3p0.timeout">300</prop>
  <prop key="hibernate.c3p0.idle_test_period">100</prop>

  <class name="Account">
    <list name="albums" cascade="save-update" inverse="false" batch-size="48">
      <cache usage="nonstrict-read-write"/>
      <key column="accountId" not-null="true"/>
      <list-index column="position"/>
      <one-to-many class="Album"/>
    </list>
  </class>
  <class name="Album">
    <cache usage="nonstrict-read-write"/>
    <id name="id" column="id" type="int">
      <generator class="increment"/>
    </id>
    <many-to-one name="account" column="accountId" not-null="true" insert="false" update="false"/>
    <property name="albumId"/>
  </class>


Code between sessionFactory.openSession() and session.close():
Code:
          Criteria c = session.createCriteria(Account.class);
          c.add(Restrictions.eq("id" , id));
          c.setMaxResults(1);
          c.setCacheable(true);
          return c.uniqueResult();


Name and version of the database you are using:
MS SQL Server


This is my situation
An Account may have a lot of (list of) albums.
When web site first loads , it is very fast to load an account (with a lot of albums).
But when the album expires in the cache , I found that hibernate tries to load the album one by one... , making loading an account very SLOW...
Is there any way to improve this ?

Thanks a lot !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 10:41 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
Can anybody help me ?
I've been stuck on this problem for two whole days.....

I've search a lot of documents...
But each time child objects (Album) expired in EhCache ,
Re-Load the Parent Object (Account) will cause n+1 SQL select ....
Not knowing what to do .... I feel very frustrated....


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.