English 中文(简体)
Derby gets stuck closing?
原标题:

I ve got unit tests (in maven) that use derby.

At the end of the test run, there is a very long pause, with these log messages before the pause.

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 config:

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

referenced from:

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

and finally 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>
问题回答

Could you try with hibernate.connection.autocommit=true? It helped me to solve some problems with the Maven Hibernate3 plugin (see HBX-1145). Not sure it s related though.

I am not sure, if this would still make a difference, but I just thought I d let you know that I knocked up a derby-maven-plugin a while ago aimed at exactly being able to run tests against a Derby database. You can have a look at the GitHub project here.





相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签