我正在尝试自动在DB上创建表,并且只想导入一次初始数据。在hibernate.cfg.xml上将“hibernate.hbm2ddl.auto”设置为“create”和“hibernate.hbm2ddl.import_files”时,它正在工作。但是,它会在每次运行时销毁并创建数据库。我想创建表,如果不存在,为此我改变参数“更新”,但这次“hibernate.hbm2ddl.import_files”不起作用。
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" />
您无需指定导入文件。 Hibernate默认情况下会看起来
WEB-INF /班/ import.sql