0

When I run the example

on my system with mvn tomcat:run command,

Data in mysql tables get's deleted.

So, I had to insert data every time I restart the application.

1
  • Do you want me to post the code here? Commented Jan 5, 2012 at 20:01

1 Answer 1

2

Assuming you followed the tutorial from the linked page exactly, the reason the MySQL data is being removed each time the application starts can be found in the hibernate.cfg.xml file.

Specifically, it's these lines:

<!-- This will drop our existing database and re-create a new one.
      Existing data will be deleted! -->
    <property name="hbm2ddl.auto">create</property>

I don't remember what the other values are off the top of my head, but I believe validate will only check that your schema is correct but not change anything. update may also work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.