简体   繁体   中英

Spring boot. Automatically create Entity classes from MySql schema

I have been working on EER diagram model for my Mysql base for the last 7 days. It is a rather complicated model with lots of connections and attributes. Now i know spring boot automatically creates tables based on your entity classes(including foreign keys and other settings) if you use spring.jpa.hibernate.ddl-auto = update in your application.properties, but is it possible to create entity classes after providing good credentials to DataSource object based on tables withing schema?

Point is i would probably need another 3-4 days of back-end coding to create all the classes with all the attribute, relationships etc.

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

There is this question Automatically create Entities from database but 1. i am using spring boot not JPA project and second blog is no longer active.

Any hints?

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

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

Hope it will help someone!!

There is this question Automatically create Entities from database but 1. i am using spring boot not JPA project and second blog is no longer active.

Under the woods, Spring boot uses JPA and more specifically Hibernate since it has bad compatibility with other JPA implmentations such as EclipseLink.

Why don't you use 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 addresses well this kind of need. The real drawback when I use it and we cannot store our orm configuration. So, since you have many tables, I advise you to generate it in an incremental way your entities.

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