-->
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: Can hibernate read the database dictionary?
PostPosted: Sun Jun 14, 2009 9:20 pm 
Newbie

Joined: Sun Jun 14, 2009 9:03 pm
Posts: 3
Hello everyone,

If I do not know the database structure, Can I use hibernate read the database dictionary?

I want to read the tables' name and fields' name. Does anybody know how can I do this, thanks.


And I find the following code, but the table iterator is empty(In fact, there are three tables)

Code:
      Configuration cfg = new Configuration().configure(new File("D:\\hibernate.cfg.xml"));
      
      for (Iterator iter = cfg.getTableMappings(); iter.hasNext();) {
         Table table = (Table) iter.next();
         for (Iterator iterator = table.getColumnIterator(); iterator
               .hasNext();) {

            Column column = (Column) iterator.next();
            System.out.println(column.getName());
         }
}


Thanks to everyone.


Top
 Profile  
 
 Post subject: Re: Can hibernate read the database dictionary?
PostPosted: Sun Jun 14, 2009 9:25 pm 
Newbie

Joined: Sun Jun 14, 2009 9:03 pm
Posts: 3
I find another code:

Code:
                  Configuration cfg = new Configuration().configure(new File("D:\\hibernate.cfg.xml"));

        SchemaExport   dbExport   =   new   SchemaExport(cfg);     
        dbExport.setOutputFile("c:/sql.txt");     
        dbExport.create(true,   true);


But unlucky, the output file sql.txt is empty too.


Top
 Profile  
 
 Post subject: Re: Can hibernate read the database dictionary?
PostPosted: Mon Jun 15, 2009 6:05 am 
Newbie

Joined: Sun Jun 14, 2009 9:03 pm
Posts: 3
Hibernate could not do this??


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.