Hibernate tool for creating basic mysql db-based mappings

Are there any tools that can look at the database and generate basic mapping files?

It would be great if he could take the database and create the actual model (java classes) with annotations, but not sure if this exists?

+4
source share
4 answers

Hibernate 3 has the Hibernate Tools toolbox that provides the Eclipse plug-in and Ant task, which support reverse engineering

Reverse engineering: The most powerful feature of Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, an annotated EJB3 beans object, HTML documentation, or even a whole JBoss Seam application in seconds!

...

Ant Task:. Hibernate3 tools include a unified Ant task that allows you to run schema generation, mapping generation, or Java code generation as part of your assembly.

For the Eclipse plugin, check out this section of the documentation. For the Ant task, read the reverse engineering section and, if necessary, manage it .

Note that other IDEs also support reverse engineering support (see Hibernate Reverse Engineering for Netbeans 6.5 and Creating persistence mappings from a database schema for IntelliJ).

+7
source

I just accidentally stumbled upon this problem, and I think I found the perfect tool for this job.

http://hibernatepojoge.sourceforge.net/


Features: (in case you are too lazy to go through the provided link)

  • Java objects representing each table, using annotations for use with Hibernate.
  • An example JUnit test for a table that uses objects created to create, populate, save, retrieve, and compare results.
  • DAO for each class
  • Matching Enumeration Files
  • Spring and sleep
  • DAO Levels
  • The factory class for each scheme for returning a pre-populated object with random data (for checking boundaries, a set of databases, etc.)

Also supports:

  • A join of tables, including those with additional fields in link tables
  • Polymorphism / inheritance support
  • Composite Keys
  • one-to-one, many-to-one, many-to-many, etc.
  • Support for multiple circuits (4 modes)
  • Natural keys
  • Enumerations (including those entries that cannot be correctly displayed in the java world)
  • A whole bunch more stuff (see sample.xml)

I would also like to say that setting this up is pretty straight forward; You just need to have the hibernate configuration file and the jar file downloaded from the site. Then it's just a question executing the jar file, passing config.xml as a parameter!

+1
source

You can find what you need here, I found it on the fly: MyGeneration .

I know that there are others that exist, but I don’t remember by heart. Hope this helps!

0
source

If you are using eclipse or ant ...

Jboss Tools

0
source

Source: https://habr.com/ru/post/1303191/


All Articles