-->
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.  [ 1 post ] 
Author Message
 Post subject: Over ride Batch Size for Lazy Fetching
PostPosted: Thu Feb 17, 2005 8:05 am 
Newbie

Joined: Thu Feb 17, 2005 7:54 am
Posts: 3
Within my mapping file I have set the associations of my object to be fetched lazily, with a batch size of 10. As part of our application it is possible to specifiy different page sizes at runtime.

I am wanting to retrieve a list of all the accounts, so that the total pages may be determined but only wish to initialise the first page of accounts. We are not using a long session approach thus the page of accounts must be initialised before rendering the page as the session is closed at this point.

When fetching objects using hibernate using a criteria object, is there any way to over ride the mapping specified batch size. If have tried using criteria.setFetchSize but this does not seem to work.

Hibernate version: 2.1.2

Mapping documents:
<class name="Account"
lazy="true"
dynamic-update="true">

<id name="id">
<generator class="native"/>
</id>

<version name="version"/>

<property name="accountCode">
<column name="accountCode"
unique="true"
length="25"
not-null="true"
index="idx_accountcode"/>
</property>

<property name="description"/>

<many-to-one name="limitGroup"
class="LimitGroup"
column="limitGroupId"
cascade="save-update"
not-null="true"/>

<many-to-one name="parent"
cascade="none"
column="parentId"
not-null="false"/>

<set name="children"
cascade="save-update"
inverse="true"
lazy="true"
batch-size="10">
<key column="parentId"/>
<one-to-many class="Account"/>
</set>
</class>

Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.getSession();
List accountList = null;
try {
accountList = HibernateUtil.getSession().createCriteria(Account.class).list();
}
catch (HibernateException ex) {
throw new InfrastructureException(ex);
}
return accountList;

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.