-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using Hibernate to get hold of the table names
PostPosted: Fri Oct 21, 2005 2:34 am 
Newbie

Joined: Wed Oct 05, 2005 9:51 am
Posts: 5
Hi !

I've been using Middlegen to create *.hbm.xml and *.java files for mapping- and class files from an existing database.

Now I want to write a method that returns all the table names in the database.

I have yet to find any good description on how this can be implemented using Hibernate.

Any good ideas out there...??

Best regards

Ted


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 3:00 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Take a peek at the JDBC meta data that is available w/ any db connection. There is also Hbm2x in the tools suite. Or, if you just want to work with the configuration you have ...

Configuration conf = new Configuration();
conf.configure();

Iterator mappings = conf.getClassMappings();
while(mappings.hasNext()){
PersistentClass clazz = (PersistentClass)mappings.next();
clazz.getTable().getName();
}


... not tested.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 3:37 am 
Newbie

Joined: Wed Oct 05, 2005 9:51 am
Posts: 5
It worked perfectly !!!

One credit to you, my friend !!

Teddy


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