The default Hibernate3 properties are stored at ejb3.deployer/META-INF/persistence.properties. You can change it in this file or in persistence.xml in your .par archive.
Where can I find a tutorial/documentation to configure Hibernate properly?
I need to know that because if I edit the above property in, for example, "create" only the tables that I created in DBserver will be erased and recreated... so I lose the data again :(
What's the correct configuration? Or where can I find a tutorial?
I have to agree, this is a very poor choice of a default value.
I wasn't paying attention to this property until my entire development database got dropped. Fortunately, our DBA had a recent backup.
Ok, this is even worse than I imagined.
The default persistence.properties file has the following two lines in it:
If you discover, either the hard way or by reading around, that create-drop is a bad choice, the natural reaction is to swap to the commented option instead.
However, create is just as bad. While my tables were not actually dropped, all of the data was removed!
I'm now running with both lines commented out, and sincerely wish the hbbm2ddl feature had never been invented. I hope these words of warning will save some other new user several hours of wasted time.
You can also add the property to the persistence xml. So it doesnt clean your data:
<properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties>
I just hit this as well when I finally connected my entities to the live database.
Aaaaargh! Good job I had a backup.
Can we change the default please?