Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 615
SeaBiscuit Avatar asked Nov 09 '15 23:11

SeaBiscuit


1 Answers

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!!

like image 84
Pavan Avatar answered Nov 15 '22 17:11

Pavan