Import initial data to the database without dropping the tables with hibernate

Viewed 87

I'm using a Spring MVC, Hibernate config over maven. On the application starts I'm importing initial data to the database from import.sql(includes some insert operations) using following configurations.

 <prop key="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</prop>
 <prop key="hibernate.current_session_context_class">thread</prop>
 <prop key="hibernate.hbm2ddl.auto">create</prop>
 <prop key="hibernate.show_sql">true</prop>

According to the documentation hibernate.hbm2ddl.auto property should be create or create-drop to execute the import.sql file . When I use that values for hibernate.hbm2ddl.auto property it executes the sql file but it drops the exiting tables and delete the previous data.

I want to import the initial data without dropping the previous tables as sometimes I have to run the application more than one time while keeping the data in the database.

Is there a way to do this?

0 Answers
Related