-->
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.  [ 5 posts ] 
Author Message
 Post subject: Arbitrary query against DB
PostPosted: Tue Jul 25, 2006 2:17 am 
Newbie

Joined: Sat Oct 15, 2005 3:30 am
Posts: 17
Hi,

Is it possible to make an arbitrary query against a database, whose columns returned from the query do not map to any particular domain object?

Or should I just drop out to ADO.NET for this?

Thanks,

Adam


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 5:27 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
If you are using Hibernate 3, the you could potential use a HQL like:

select new Name(per.First_Name,per.last_name) from Person

If you don't specify the "new Name" then you'll get an Object[] []containing the values.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 7:03 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
yes, it is possible with NHibernate as well.

cheers,
Radu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 7:16 pm 
Newbie

Joined: Sat Oct 15, 2005 3:30 am
Posts: 17
Hi,

So if I use the new syntax as you describe above,

Do I need a Name class that Nhibernate knows about (eg has some mapping file associated with it), or can it just be a standard c# class?

Thanks,

Adam


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 25, 2006 7:23 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
No, you don't. I have used HQL to return a list of strings that I used to populate a dropdown list. You can't use HQL for a completely arbitrary query, you can only select properties of already mapped objects.

cheers,
Radu


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