2

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
kaffein
  • 1,766
  • 2
  • 28
  • 54
  • http://stackoverflow.com/questions/438146/hibernate-question-hbm2ddl-auto-possible-values-and-what-they-do/1689769#1689769 – NimChimpsky Sep 28 '11 at 09:39

2 Answers2

1

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

Behrang
  • 46,888
  • 25
  • 118
  • 160
0

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

ayengin
  • 1,606
  • 1
  • 22
  • 47
  • Hi guyz, thanks a lot for your responses. Actually, after diving into the logs, I saw that the user I have configured in the app to connect to the DB didn't have the privileges to ALTER TABLES : so my sysadmin changed that and now it works ;-) – kaffein Sep 29 '11 at 13:28