-->
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: Query only returns data
PostPosted: Thu Jun 08, 2006 9:42 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Hibernate version: 1.02 (self compiled)

Hi. Is there any way to see the fields returned by a query? Using IQuery.List() I can't know what are the names of the fields returned.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 12:44 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
No, hibernate throws away the result set's metadata after it has constructed the objects. To access the metadata, you have to use the database connection the "old fashioned" way, without hibernate.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 09, 2006 7:54 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
What if we could configure it? And we could access it like this:

Code:
IQuery query = session.CreateQuery(MyQuery);
query.List();
string[] s  = query.Metadata;


I think it's interesting.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 11, 2006 7:30 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The whole point of hibernate is to protect you from all of that. If you want the metadata, use JDBC or whatever the .net equivalent is.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 12, 2006 9:09 am 
Beginner
Beginner

Joined: Mon Mar 06, 2006 2:19 pm
Posts: 42
Location: Belo Horizonte, Brazil
Ok, I understand. I was asking because there are some times that I want to return a DataTable as the result of some HQL's. I want to name the DataTable columns with the metadata. What I'm doing is use reflection to get the names from the properties.

Based in your last post I don't know if I am doing the right thing now.

Thanks.


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.