Tell me what you need to put in the config file Hibernate so that when creating a new database, it was filled with the data from the script files import.sql. Application using Hibernate, MySql, Spring, Tomcat, Maven. If the database does not exist then it is created automatically.
hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <property name="hibernate.connection.autocommit">false</property> <property name="current_session_context_class">thread</property> <property name="hibernate.enable_lazy_load_no_trans">true</property> <mapping class="controller.User" /> </session-factory> </hibernate-configuration> hibernate version:
<groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.2.7.SP1</version>