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: Retrive single coumn fron database
PostPosted: Tue Sep 09, 2008 6:15 am 
Newbie

Joined: Tue Sep 09, 2008 3:20 am
Posts: 17
Hi

I am new to NHibernate, I have created a maping file for all the columns in a table Customer this works and gives me all the vaues in the table.
But for a perticular case i need only the customerId of all the customer,
is there any way to retrive only this column using the same mapping file.

Thanks

Arvind


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 6:44 am 
Regular
Regular

Joined: Tue Jul 29, 2008 3:30 am
Posts: 74
I think IQuery.Enumerable() is what you are searching for. I've never used it myself but the documentation says that it's returning a list of proxy objects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 7:58 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You can use a projection either with HQL:

IQuery q = session.CreateQuery("select c.id from Customer c")

or with a criteria

ICriteria c = session.CreateCriteria(typeof(Customer),"c")
.SetProjection(Projections.Id());

Then either q.List<int>() or c.List<int>() returns a list of the ids.

_________________
--Wolfgang


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.