2

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

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

信息:关闭 Hibernate SessionFactory
2009 年 11 月 16 日晚上 8:30:31 org.hibernate.impl.SessionFactoryImpl 关闭
信息:关闭
2009 年 11 月 16 日 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport 执行
信息:运行 hbm2ddl 模式导出
2009 年 11 月 16 日 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport 执行
INFO:将生成的模式导出到数据库

休眠配置:

<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"/>

最后是行家:

 <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>
4

2 回答 2

0

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

于 2010-05-26T21:58:14.230 回答
0

我不确定这是否仍然会产生影响,但我只是想让您知道,我不久前敲开了一个 derby-maven-plugin,旨在完全能够针对 Derby 数据库运行测试。您可以在此处查看 GitHub 项目。

于 2013-02-25T17:43:17.147 回答