-->
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: Sorting/Filtering/Paging Child Collections
PostPosted: Thu Mar 25, 2010 10:43 am 
Newbie

Joined: Thu Mar 25, 2010 10:03 am
Posts: 1
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...
Image

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.


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.