Java – Hibernate: make database only if not exists

hibernatejava

I want Hibernate make database file (SQLite), but only if not exists.

Now in hibernate.cfg.xml I have this line:

<property name="hibernate.hbm2ddl.auto">create</property>

The problem is that database file is been creating in all the time, even the file exists.

Best Answer

Try switching the value to update

<property name="hibernate.hbm2ddl.auto">update</property>