简体   繁体   中英

Reverse Engineering a Hibernate Database Structure

I'm thinking about writing some code for a project where it is likely that there will be several different hibernate structured databases, about which little or nothing will be known.

The code will ideally be able to receive objects (serialized, transmitted over http) and based on the database connection it has been given, decide if the object fits and if so, persist it.

Is there an established or relatively straightforward way to generate the persistence.xml or the class structure based on access to the database and the metadata?

There are a few options here. Eclipse has a hibernate reverse engineering tool, here's a howto on using it:

http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables

Install the hibernate tools from the JBoss update site if you don't already have them (Help -> Software Updates... -> Add Site...):

http://download.jboss.org/jbosstools/updates/stable/

I've used this tool a few times and it does a pretty good job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM