0

I am trying to create tables on DB automatically and want to import initial data only once. It is working when set the "hibernate.hbm2ddl.auto" to "create" and "hibernate.hbm2ddl.import_files" on hibernate.cfg.xml. However, it destroys and create DB every run. I want to create tables if not exist, to do that I changed paramater to "update", but this time "hibernate.hbm2ddl.import_files" is not working.

org.apache.derby.jdbc.EmbeddedDriver jdbc:derby:CounterDB;create=true 5

<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.current_session_context_class">thread</property>

<property name="hibernate.show_sql">true</property>
<!-- Creates it only if it doesn't exist -->
<property name="hibernate.hbm2ddl.auto">update</property>

<!-- import initial data to Database when it created -->
<property name="hibernate.hbm2ddl.import_files">import.sql</property>

<!-- Mapping files -->
<mapping class="com.counter.db.CameraSettings" />
<mapping class="com.db.Counts" />

1 Answer 1

1

You don't need to specify the import files. Hibernate will look by default at

WEB-INF/classes/import.sql

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.