-->
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: Fetching column names
PostPosted: Mon Feb 05, 2007 7:12 am 
Newbie

Joined: Sat Dec 02, 2006 4:23 am
Posts: 17
Hi all,
I want to fetch the column names of the table for which i have written mapping , Bean class, cfg file.
Can anyone help me in doing that.
Regards,
Jasmine


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 3:08 am 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
Hi, you got any solutions ?? I facing the same problem. Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 3:08 am 
Beginner
Beginner

Joined: Tue Jan 30, 2007 1:35 pm
Posts: 27
Hi, you got any solutions ?? I facing the same problem. Thanks in advance.


Top
 Profile  
 
 Post subject: Fetching column names from existing Database
PostPosted: Tue Feb 06, 2007 5:41 am 
Newbie

Joined: Sat Dec 02, 2006 4:23 am
Posts: 17
Hi,
Still i couldnt find solutions for this.Even i posted again in forum.If you find any solution please let me know.

Regards,
Jasmine


Top
 Profile  
 
 Post subject: Post subject: Fetching column names from existing Database
PostPosted: Tue Feb 06, 2007 5:45 am 
Beginner
Beginner

Joined: Wed Jan 31, 2007 6:54 am
Posts: 22
Hi,
dont know if this is what you are looking for, but this was a hack I found on a some website time ago, sorry dont remember the reference... It allows you the get the associated table name for a given class:


Code:
   public String getTableName(Class aClass){
      SessionFactoryImpl sessionFactory = (SessionFactoryImpl) mSessionFactory;
      return ((SingleTableEntityPersister)(sessionFactory.getClassMetadata(aClass))).getTableName();
   }


Top
 Profile  
 
 Post subject: Re: Post subject: Fetching column names from existing Databa
PostPosted: Tue Feb 06, 2007 7:12 am 
Newbie

Joined: Sat Dec 02, 2006 4:23 am
Posts: 17
Hi all,
Try this code to fetch column names.

String[] colnames=HibernateUtil.getSessionFactory.getClassMetaData("myPackage.classname").getPropertyNames();

Then iterate through the string array to get required column names.

Regards,
Jasmine.


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.