0
对于测试问题,我想创建一个内存数据库。其中一个表格默认应该有内容。我该怎么做呢? 我试着用以下配置:创建内存数据库休眠并加载数据
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;INIT=CREATE SCHEMA IF NOT EXISTS `test`;</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="hibernate.default_schema">test</property>
<property name="connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.hbm2ddl.import_files">initial_data.sql</property>
</session-factory>
文件initial_data.sql很简单:
INSERT INTO test.email_template(template_id, description, subject, text, sender, reply_to)
VALUES('1','Confirm','Your registration','Some content here','[email protected]',NULL);
但是当我开始测试,我得到以下错误:
org.hibernate.tool.hbm2ddl.SchemaExport : HHH000388: Unsuccessful: VALUES('1','Confirm','Your registration','Some content here','[email protected]',NULL)
2016-12-29 13:53:30.826 ERROR 6560 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : Method is not allowed for a query. Use execute or executeQuery instead of executeUpdate; SQL statement:
出了什么问题?
例外情况和相关代码。 –
给出的例外是我得到的一切。 – Kahuna