Spring boot. Automatically create Entity classes from MySql schema

I have been working on an EER chart for my Mysql database for the past 7 days. This is a rather complex model with many connections and attributes. Now I know that spring boot automatically creates tables based on your entities (including foreign keys and other parameters) if you use spring.jpa.hibernate.ddl-auto = update in your .properties applications, but is it possible to create object classes after providing good credentials to a table-based DataSource?

Point - I probably need another 3-4-day coding to create all classes with all attributes, relationships, etc.

Given the fact that this can only be done in one correct way, based on schematic tables, and this is not really rocket science. Why not do it just once?

This question arises. Automatically create entities from the database but I use spring boot not JPA project, and the second blog is no longer active.

Any clues?

+6
source share
2 answers

Just figured it out. I used the hibernate perspective in eclipse to connect to the database, create cfg.xml and run the project as sleeping configurations, create a new reveng.xml configuration and that will work. A more detailed answer can be found in the next article.

http://o7planning.org/en/10125/using-hibernate-tools-generate-entity-classes-from-tables

Hope this helps someone!

+3
source

This question arises. Automatically create entities from the database, but 1. I am using spring boot not JPA project, and the second blog is no longer active.

In the spring forest, boot uses JPA and, more specifically, Hibernate, as it has poor compatibility with other JPA applications such as EclipseLink.

Why don't you use the Dali Eclipse plugin? https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm

It has a wizard with many options, and it copes well with such a need. The real flaw when I use it and we cannot save our orm configuration. Therefore, since you have many tables, I advise you to generate it in stages, so that your entities.

0
source

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


All Articles