A
A
Amurchikus2015-12-25 17:31:15
Java
Amurchikus, 2015-12-25 17:31:15

How to create tables correctly with Hibernate?

I greet you dear!
Please help. I want to find an answer to how to create tables in an empty database (mysql) using Hibernate, is this possible and how expedient is it?
Are there any examples or links. I will be very grateful for your help!
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bromzh, 2015-12-25
@Amurchikus

Maybe. It is advisable if the models and relationships are more or less simple. You just need to set the property named "hbm2ddl.auto" to "update".
It is achieved by adding a line to the persistence.xml config:
You can also configure it programmatically, google how.

V
Victor Alenkov, 2016-01-07
@Borz

for myself I did this:
0) on the product and preproduction database for Hibernate there are no rights to change the schema. But there are such rights for Flyway, which already manages changes in the database schema
1) Hibernate has full rights to the developers' database and hbm2ddl.auto=update. flyway disabled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question