Hi all,
I'm new to ORMs so I might be doing something horribly wrong - if I am I apologise in advance!
I've got a basic testing DB setup...
with mappings set up like:
Code:
<class name="Category" table="Categories">
<id name="ID" column="ID">
<generator class="native" />
</id>
<property name="Display" column="Display" length="50" not-null="true" />
<property name="Hidden" column="Hidden" type="Boolean" />
<set name="Listings" table="Categories_Listings" lazy="true">
<key column="CategoryID" />
<many-to-many class="Listing" column="ListingID" />
</set>
</class>
<class name="Listing" table="Listings">
<id name="ID" column="ListingID">
<generator class="native" />
</id>
<property name="BusinessName" column="BusinessName" length="200" not-null="true" />
<property name="Hidden" column="Hidden" type="Boolean" />
</class>
I'm trying to retrieve a category with the children (listings) sorted alphabetically, filtered so only the ones where hidden = false are returned, and paged so only retrieve n children. I can use the sort/filter attributes in the XML mappings to do what I'm after I don't always want to sort by the same column.
Is there a way to do this in one query (without manually sorting the listings afterwards)? Or is it better to get the category in one query, and the listings separately in another?
Thanks in advance for any help.