-->
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.  [ 6 posts ] 
Author Message
 Post subject: How do i get Column Names from the Query Object ?
PostPosted: Fri Dec 01, 2006 3:02 am 
Newbie

Joined: Thu Nov 23, 2006 1:42 am
Posts: 5
Query q = createQuery("from Ordermaster");

I want to get the following information from the result:

1). Column Names
2). Column Count

I tried giving alias in the query -

q = "select om.OrderId as OrderNo from OrderMaster"

and then used q.getReturnAliases();

Its working but if there is some easy way out, please help. This way shall be too cumbersome.

Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 5:21 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Maybe this can help you:

http://www.hibernate.org/hib_docs/v3/re ... e-metadata

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject: Sorry but it wont help much..
PostPosted: Fri Dec 01, 2006 6:42 am 
Newbie

Joined: Thu Nov 23, 2006 1:42 am
Posts: 5
I need to extract Column Names from the Result i get after running a query... As we can get by using MetaData Information of java.sql.ResultSet Object....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 7:02 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
With hibernate you obtain objects (POJOs) as the result of a query.

So the "column names" are the properties of that POJOs.

Query.getReturnTypes() tell you what POJOs are being returned if you don't know previously what types your query are going to return...

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject: getRtrntyp() gives me Type[] of the columns only
PostPosted: Mon Dec 04, 2006 8:03 am 
Newbie

Joined: Thu Nov 23, 2006 1:42 am
Posts: 5
I need Column Names.

How do ui get Column Names? Its just giving me Types like org.hibernate.type.LongType@191e0eb

------------------------------------------------------------------------------------

andresgr wrote:
With hibernate you obtain objects (POJOs) as the result of a query.

So the "column names" are the properties of that POJOs.

Query.getReturnTypes() tell you what POJOs are being returned if you don't know previously what types your query are going to return...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 9:50 am 
Regular
Regular

Joined: Mon Jul 31, 2006 4:59 pm
Posts: 53
The answer is in the Pojos which you receive. For example:

Code:
public class User {

private String name;
private String street;

public String getName() {
return this.name;
}

public String getStreet() {
return this.street;
}

public void setName(String name) {
this.name = name;
}

public void setStreet(String street) {
this.street = street
}

}


Here are the column-names "street" and "name". You can see this in your Pojo-Mappings. You have to work with Objects, not with relational data.


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