kaffein
kaffein

Reputation: 1766

How to get automatic SCHEMA UPDATE on an existing DB with JPA/Hibernate?

I am trying to update my existing DB schema automatically with JPA-based app (I am using Hibernate as a Persistence provider). What I did is that I have positioned my hbm2dll param to "update" like this in the persistence.xml :

 <properties>
     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
     <property name="hibernate.hbm2ddl.auto" value="update"/>
     ...
 </properties>

But it seems that Hibernate can not handle the schema generation.

Can you please tell me how I can automatically update my running DB schema with JPA/Hibernate if any other option than the hbm2dll is available?

Upvotes: 2

Views: 6531

Answers (2)

ayengin
ayengin

Reputation: 1596

Your setting is correct ,but database must be created manually.Hibernate will create tables.And you can also set value to create,update .

Upvotes: 0

Behrang Saeedzadeh
Behrang Saeedzadeh

Reputation: 47913

Don't do that in production. Write your schema manually and then maintain it using Liquibase or something similar.

Upvotes: 1

Related Questions