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 !