Reputation:
I know it's possible to reverse engineer from the database into mapping files but does anyone know if it's possible to get hibernate to draw an ERD based on its own mapping files so that I can compare Hibernate's ERD with the Databases one?
Upvotes: 0
Views: 1933
Reputation: 41
By Default hibernate creates MySql MyIsam Database which has internal connections instead of foreign keys so MySQL WORCKBENCH or VISUAL PARADIGM wont show ERD properly with connections make sure in application.properties inside resources to create this statement.
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL55Dialect
instead of
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
which creates MyISAM, watch for the double 5 this is the key here to change mode
Upvotes: 0
Reputation: 38
Yes, it's possible. As far as I know you can't do it directly from the mappings but instead you have to generate the database first.
What you have to do is simple:
Upvotes: 0
Reputation:
I achieved this by using:
<property name="hibernate.hbm2ddl.auto">create-drop</property>
in my hibernate.cfg.xml
Then I used MySQL Workbench to reverse engineer an ERD from my database that was created by Hibernate.
Upvotes: 1