德比陷入困境?

时间:2009-11-17 01:32:57

标签: maven-2 derby surefire

我有使用德比的单元测试(在maven中)。

在测试运行结束时,有一个非常长的暂停,在暂停之前会显示这些日志消息。

INFO: Closing Hibernate SessionFactory
Nov 16, 2009 8:30:31 PM org.hibernate.impl.SessionFactoryImpl close
INFO: closing
Nov 16, 2009 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Nov 16, 2009 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database

Hibernate配置:

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
        <property name="hbm2ddl.auto">create-drop</property>
        <property name="show_sql">false</property>
    </session-factory>
</hibernate-configuration>

引自:

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <!-- data source elsewhere -->
    <property name="dataSource" ref="dataSource" />
    <property name="mappingResources">
      <list>
        <value>com/basistech/configdb/dao/Gazetteer.hbm.xml</value>
        <value>com/basistech/configdb/dao/FileGazetteer.hbm.xml</value>
        <value>com/basistech/configdb/dao/Regexpset.hbm.xml</value>
        <value>com/basistech/configdb/dao/Redactjoiner.hbm.xml</value>
        <value>com/basistech/configdb/dao/Misc.hbm.xml</value>
      </list>
    </property>
    <property name="configLocation" value="classpath:com/basistech/configdb/dao/hibernate.xml"/>

最后是maven:

 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>codegen</id>
                        <goals>
                            <goal>hbm2java</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                          <components>
                            <component>
                              <name>hbm2java</name>
                            </component>
                          </components> 
                            <componentProperties>
                                <configurationfile>src/main/hibernate/codegen-hibernate.xml</configurationfile>
                            </componentProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

2 个答案:

答案 0 :(得分:0)

你可以试试hibernate.connection.autocommit=true吗?它帮助我解决了Maven Hibernate3插件的一些问题(参见HBX-1145)。不确定它是否相关。

答案 1 :(得分:0)

我不确定,如果这仍然会有所作为,但我只是想让我知道我刚刚敲了一个derby-maven-plugin,旨在完全能够对Derby进行测试数据库。您可以查看GitHub项目here