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.  [ 4 posts ] 
Author Message
 Post subject: Filter Child Collections
PostPosted: Wed Oct 11, 2006 5:18 am 
Newbie

Joined: Wed Oct 11, 2006 5:08 am
Posts: 2
Let us suppose there is some AddressBook class. Inside is a collection of Contacts. What I want to be able to do is say something like this in the query:

from AddressBook as book where book.Contacts.LastName = "Smith"

Where, when the query is fired, my object heiarchy is not broken, and the internal list of contacts inside the AddressBook class is filtered, and returned inside the AddressBook object, instead of being returned along side the book class in some Object[], which would happen with a fetch or a join.

So...I'm confused, I don't see how in the documentation, perhaps I missed it, but I don't see how you can filter internal collections of objects using the query language.

If someone knows a way to do this...or the accepted alternative, please tell me, because some objects with collections may have serveral thousand items in the collection, which I would never want all to appear in the list at once on a query.

Also...perhaps it just hasn't been implemented, but is it possible to use Generics for internal collections yet? Currently I get a casting error if I try to set my "Contacts" list to IList<Contact> inside of the address book class, and I'm forced to use the regular IList instead.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 5:34 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can't do that. NHibernate will always return you the full collection of contacts. AddressBook.Contacts will always contain all its contacts, no matter where you got the AddressBook from.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 5:40 am 
Newbie

Joined: Wed Oct 11, 2006 5:08 am
Posts: 2
:(

Is there any chance this could be added? It would be really useful.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 11, 2006 5:44 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No chance - this is by design. Use queries or CreateFilter.


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

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.