-->
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.  [ 4 posts ] 
Author Message
 Post subject: How can i retrieve structure of a database?
PostPosted: Wed Dec 17, 2003 5:29 am 
Newbie

Joined: Wed Dec 17, 2003 5:16 am
Posts: 2
Location: P.R.China
Having a database with some tables within, how can I retreive names of these tables with Hibernate and create corresponding persistent classes?

cheers!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 7:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at middlegen

_________________
Emmanuel


Top
 Profile  
 
 Post subject: it bogs down when running as servlet
PostPosted: Thu Dec 18, 2003 3:57 am 
Newbie

Joined: Wed Dec 17, 2003 5:16 am
Posts: 2
Location: P.R.China
yes i can retrieve tables' names by using APIs of MiddleGen. Unfortunate it doesn't work when running as a servlet. code fragment is pasted below:

Middlegen middlegen = new Middlegen(null);
Database database = new StandardDatabase("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "root", "");




MiddlegenPopulator middlegenPopulator = new MiddlegenPopulator(middlegen, database, "test", "", new HashMap());

// read all regular tables
middlegenPopulator.addRegularTableElements();
middlegenPopulator.populate(middlegen.getTableElements());

//above line will throw an exception of concurrent connection in action of closing connections of database in servlet but it works as a standalone application...

middlegenPopulator.closeConnection();

Iterator it=middlegen.getTables().iterator();

while(it.hasNext()){
Table te=(Table)it.next();
System.out.println(" -table name is:"+te.getTableElement().getName());
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Why would you run Middlegen from a servlet?

Its designed to be a build tool assistant. Normally run from an Ant script.


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