Search code examples
javamysqlhibernatespring-roo

Restarting a Roo-application flushes its correspondant MySQL-table


I've got a Roo-project. Its data is persisted into a MySQL-database (via Hibernate).

When I restart Tomcat the Roo-applications correspondant MySQL-table gets completely flushed. All data which is already in the table is deleted.

How can I keep the data?


Solution

  • Try to play with Hibernate's persistence settings ({project_root}/src/main/resources/META-INF/persistence.xml). There is the line:

            <!-- value="create" to build a new database on each run; value="update" 
                to modify an existing database; value="create-drop" means the same as "create" 
                but also drops tables when Hibernate closes; value="validate" makes no changes 
                to the database -->
            <property name="hibernate.hbm2ddl.auto" value="update" />
    

    Set there validate.