2011-02-25 5 views
2

. 문제 DBUnit를 받는다는 플러그인 내가 만들고 Hibernate3는-받는다는 - 플러그인과 DBUnit를-받는다는 - 플러그인 받는다는 플러그인을 사용하여 메모리에 HSQL DB를 스키마를 채우는 만들려고하고

나는 파일에 그것을 할 관리,하지만 메모리에 더. 최대 절전 모드 플러그인은 불평없이 작업을 수행하지만, 한 번 플러그인을 최대 절전 모드 완료, 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) 

¿ 어떤 사람은 어떤 생각을 가지고 있습니까?

덕분에 많은

답변

0

URL은 마지막 연결이 종료 될 때 데이터베이스가 종료해야 나타냅니다. 이것은 파일 데이터베이스 (비록 필요하지는 않지만)에서 작동하지만 메모리 데이터베이스를 닫고 버립니다. 다음과 같이 URL을 변경합니다

hibernate.connection.url=jdbc:hsqldb:mem:mytestdb;shutdown=false 

이 하나

<url>jdbc:hsqldb:mem:mytestdb;shutdown=false</url> 
+0

답장을 보내 주셔서 감사합니다.하지만 그 일은 나에게 도움이되지 못했습니다. 원래 이러한 db urls가 있었지만 결과가 나타나지 않았기 때문에 shutdown 매개 변수와 hsqldb.write_delay를 사용하기 시작했습니다. 어떤 경우에 주셔서 감사합니다 :) –

+0

확실히 shutdown = false로 작동하지 않으면 hibernate 및 dbunit에 다른 Java 프로세스를 사용 중입니다. 이 유형의 설정에서는 메모리 데이터베이스가있는 HSQLDB 서버를 사용해야합니다. – fredt