Hibernate version:1.2.0.4000
Mapping documents:Xml Configuration
Name and version of the database you are using:SQLServer 2005 Express Edition
-----------------------------------------------------------------
I have a problem when trying to display data paged.
when i call SetFirstResult and SetMaxResults, NH executes a query finding database identifiers in the range, then creates and executes n query based on n identifiers returned.
i thought "batch-size" attribute in class declaration in hbm configuration files can be used for that (i.e. instead of executing n queries, execute 1 query for all passing identifiers)
(13) batch-size (optional, defaults to 1) specify a "batch size" for fetching instances of this class by identifier. , NH doc, section 5.1.3 class
but after i applied batch to 10 or 25, no things differed. also i try below configuration '<add key="hibernate.batch_size" value="2">' in NH configuration. but nothing changed.
my question is: how can say NH to load 10 rows each time?
below is my class hbm:
--------------------------------------------------
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Mehan.Navand.EntityLayer" assembly="Mehan.Navand.EntityLayer">
<class name="ContactEntity" table="OrmContacts_ContactsTable" batch-size="25">
<id name="Id" type="string" unsaved-value="null">
<generator class="uuid.hex" />
</id>
<version name="Version" unsaved-value="-1"/>
<property name="CreationDate" type="datetime"/>
<property name="Confirmed"/>
<property name="BankName" />
<property name="BankAccount" />
<property name="BankCardNumber" />
<property name="Birthday" type="datetime" />
<property name="BusinessAddress" />
<property name="BusinessAddressCity" />
<property name="BusinessAddressProvience" />
<property name="BusinessAddressCountry" />
<property name="BusinessAddressStreet" />
<property name="BusinessEmail" />
<property name="BusinessFax" />
<property name="BusinessName" />
<property name="BusinessOrganization" />
<property name="BusinessPhone" />
<property name="BusinessRole" />
<property name="BusinessUrl" />
<property name="BusinessWeblog" />
<property name="CellNumber" />
<property name="ForeName" />
<property name="GoogleId" />
<property name="HomeAddress" />
<property name="HomeAddressStreet" />
<property name="HomeAddressCity" />
<property name="HomeAddressProvience" />
<property name="HomeAddressCountry" />
<property name="HomeFax" />
<property name="HomePhone" />
<property name="IcqId" />
<property name="LastName" />
<property name="MarriageDate" type="datetime" />
<property name="Memo" />
<property name="NickName" />
<property name="PersonalEmail" />
<property name="PersonalUrl" />
<property name="PersonalWeblog" />
<property name="Title" />
<property name="YahooId" />
<property name="Gender" />
<set name="Properties" cascade="all-delete-orphan" lazy="true">
<key column="Contact"/>
<one-to-many class="ContactPropertyEntity"/>
</set>
<bag name="Labels" lazy="true" table="OrmContacts_ContactLabelsTable">
<key column="ContactId"/>
<element type="string" column="Label"/>
</bag>
<many-to-one cascade="none" name="Owner" column="OwnerId" class="MemberEntity" />
</class>
</hibernate-mapping>
thanks in advance