我正在尝试使用 hibernate3-maven-plugin 和 dbunit-maven-plugin maven 插件在内存中创建和填充 hsql 数据库模式。
我设法对文件进行了处理,但对内存没有。hibernate 插件在没有抱怨的情况下完成了它的工作,但是一旦 hibernate 插件完成,dbunit 就会抱怨 db 模式,它看起来不再存在了。正如我所说,我在文件中完美地使用了 hsql db,但没有设法在内存中做到这一点。
这是休眠插件代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hsqlDB</id>
<phase>test-compile</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<propertyfile>target/test-classes/hibernateconf.properties</propertyfile>
<configurationfile>target/test-classes/hibernate.cfg.xml</configurationfile>
<skip>${skipTests}</skip>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</plugin>
hibernateconf.properties 包含:
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.connection.url=jdbc:hsqldb:mem:mytestdb;hsqldb.write_delay=false;shutdown=true
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.connection.pool_size=1
hibernate.hbm2ddl.auto=create-drop
这是 dbunit
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<dataTypeFactoryName>org.dbunit.ext.hsqldb.HsqldbDataTypeFactory</dataTypeFactoryName>
<driver>org.hsqldb.jdbcDriver</driver>
<username>sa</username>
<password></password>
<url>jdbc:hsqldb:mem:mytestdb;shutdown=true;hsqldb.write_delay=false</url>
<src>src/test/resources/sample-data.xml</src>
<type>CLEAN_INSERT</type>
<skip>${skipTests}</skip>
<transaction>true</transaction>
<skipOracleRecycleBinTables>true</skipOracleRecycleBinTables>
</configuration>
<executions>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>operation</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</plugin>
这是错误消息:
Caused by: org.dbunit.dataset.NoSuchTableException: ExamplePersonEntity
at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:281)
有人有什么主意吗?
非常感谢