-->
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: Rerturn Columns names
PostPosted: Sun Dec 18, 2005 5:19 am 
Newbie

Joined: Thu Oct 20, 2005 8:30 am
Posts: 10
Hello to all!!I have a problem, how do i return the columns names, I know how to return the data from my database, but I have no idea how to return the columns names, does somebody know?Thanks a lot!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 5:31 pm 
Newbie

Joined: Mon Dec 12, 2005 11:37 am
Posts: 14
Not sure why you would want to get the column names - because the whole purpose of using H would be to NOT to deal with column names and just deal with properties.

However, if you insist, you can do this in 2 ways:

1. Use straight JDBC

// get teh JDBC connection
Connection conn = session.connection();
DatabaseMetadata dbmd = conn.getMetaData();
// and then from the here get teh table and then the columns and names etc.

// look up the JDBC API for more details


2. Use the Configuration

Configuration.getClassMapping("SomeClass").getTable().getColumnIterator();

// I think this returns a list of String column names - check the H API for more details

Hope this helps

Shantanu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 10:37 pm 
Newbie

Joined: Thu Oct 20, 2005 8:30 am
Posts: 10
Hi!I need the column names because, I want to display them in table. That's what I want!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 11:04 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Wouldn't you be better off displaying the property names? Or even better, to internationalize your code, use a properties file (Application.properties.EN, Application.properties.DE, etc.: see ResourceBundle in your JDK javadocs).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 10:37 am 
Newbie

Joined: Mon Dec 12, 2005 11:37 am
Posts: 14
Well .. I guess my previous post did explain how to get the column names - if you so want it:)


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.