-->
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.  [ 3 posts ] 
Author Message
 Post subject: wishing for IQuery.GetDataSet or something similar
PostPosted: Fri Mar 31, 2006 11:37 am 
Newbie

Joined: Fri Mar 31, 2006 11:18 am
Posts: 5
Whereas the NH code base now includes preliminary support for generics, I decided to try to switch my project from using WilsonORMapper to NH. One of the things I'm missing from WORM is the GetDataSet method.

I have several views in my app that display a limited set of properties from a set of entities. I can craft a query very easily that will only "select" the properties I need in the view, but the format of the returned results (a list of arrays) I am finding difficult to deal with.

Am I overlooking something that will work as well or better than what I'm asking for?

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 1:58 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html#mapping-declaration-import
http://www.hibernate.org/hib_docs/nhibernate/html/queryhql.html#queryhql-select

You can create a class of just the properties you want, import it in the mapping, then HQL like:
Code:
select new FooLite( f.Name, f.Email ) from Foo as f where f.IsEmployee = true


You will get back a collection of FooLite objects instead of an object[]*. This can be bound using databinding.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 2:40 pm 
Newbie

Joined: Fri Mar 31, 2006 11:18 am
Posts: 5
That's pretty good, k-dub. I guess the only significant drawback is that the set of properties that can be returned is rigid. In other words, it won't be practical to allow the user to select visible columns from all possible properties and then dynamically construct a query.

The other option that I am considering is using a hybrid NH/ADO.Net approach. I wanted to be pure NH, but I may have to sacrifice.

Thanks for the help.

Regards,
Daniel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.