At line 13 changed 1 line. |
* [4] Start HSQL and run tests |
* [4] Modify applicationContext-hibernate.xml |
* [5] Start HSQL and run tests |
At line 18 added 2 lines. |
[Download HSQLDB|http://prdownloads.sourceforge.net/hsqldb/hsqldb_1_8_0_2.zip?download] from SourceForge. Create a lib/hsqldb-1.8.0 directory and put hsqldb.jar in this directory. |
|
At line 22 added 11 lines. |
Open lib/lib.properties and add the following entry: |
|
{{{ |
# |
# HSQLDB - http://hsqldb.sourceforge.net |
# |
hsqldb.version=1.8.0 |
hsqldb.dir=${lib.dir}/hsqldb-${hsqldb.version} |
hsqldb.jar=${hsqldb.dir}/hsqldb.jar |
}}} |
|
At line 21 changed 1 line. |
!!Start HSQL and run tests [#4] |
Uncomment the database entries in build.properties and use the following settings (or just copy/paste these). |
At line 37 added 5 lines. |
{{{ |
database.jar=${hsqldb.jar} |
database.type=hsql |
database.name=appfuse |
database.host=localhost |
At line 24 changed 1 line. |
Start HSQLDB as a service: http://www.waldhor.com/hsql.htm |
hibernate.dialect=org.hibernate.dialect.HSQLDialect |
database.driver_class=org.hsqldb.jdbcDriver |
database.url=jdbc:hsqldb:${database.type}://${database.host}/${database.name} |
database.username=sa |
database.password= |
}}} |
|
!!Modify applicationContext-hibernate.xml [#4] |
You need to turn off batch processing for Hibernate for things to work with HSQL. In ''src/dao/**/applicationContext-hibernate.xml'', uncomment the following line: |
|
{{{ |
<prop key="hibernate.jdbc.batch_size">0</prop> |
}}} |
|
!!Start HSQL and run tests [#5] |
|
HSQLDB doesn't ship with a way to start and run it as a service. However, there is a way to configure HSQLDB to [run as a service|http://www.waldhor.com/hsql.htm]. Following these instructions, you can install an HSQL service running the "appfuse" database. Just [download the hsql.exe and hsql_service_install.bat|http://www.waldhor.com/hsql.zip] and change the hsql_service_install.bat to contain the following. The settings below assume you've extracted the hsqldb download to c:\Tools\hsqldb and that you've install the downloaded files into the same directory. |
|
{{{ |
net stop HSQLService |
hsql.exe -uninstall HSQLService |
set EAGLE_MEMEX_BIN=c:/tools/hsqldb/lib |
set DATABASE=c:/tools/hsqldb/data/appfuse |
set CURRENTDIR=c:/tools/hsqldb/data |
hsql.exe -install HSQLService "%JAVA_HOME%\jre\bin\server\jvm.dll" -jvm_option -Xms128m -Xmx128m -Djava.class.path=".;%EAGLE_MEMEX_BIN%\hsqldb.jar" -jvm_option -Dsystem.drive="c:" -start org.hsqldb.Server -params -database.0 %DATABASE% -dbname.0 appfuse -current "% CURRENTDIR%" -out "%CURRENTDIR%/service.out" -err "%CURRENTDIR%/service.err" |
net start HSQLService}}} |
|
Another option is to simply create script (i.e. run-hsqldb.bat) in your project's directory that you can use to start HSQLDB. |
{{{ |
java -cp lib/hsqldb-1.8.0/hsqldb.jar org.hsqldb.Server -database.0 c:/temp/appfuse-db -dbname.0 appfuse |
}}} |
If you write model objects with Boolean values, you may find that DBUnit fails. A quick fix for this is to add a reference to DBUnits custom data types. |
|
Unfortunately, the generally accepted remedy does not seemd to work, namely: |
|
{{{ |
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="dao.test.classpath" |
datatypeFactory="ca.ottawa.eiad.eventscal.util.HsqlDataTypeFactory" |
/> |
|
}}} |
The quick and dirty fix for this seems to be to add the factory whereever it's needed, e.g. |
{{{ |
<target name="db-export" depends="prepare" |
description="Exports the current data in the database"> |
<dbunit driver="${database.driver_class}" url="${database.url}" |
datatypeFactory="org.dbunit.ext.hsqldb.HsqldbDataTypeFactory" |
userid="${database.username}" password="${database.password}"> |
<export dest="db-export.xml" format="xml"/> |
</dbunit> |
</target> |
}}} |
|
The db-load target or anything else that uses DBUnit will need a similar quickfix, so a request has been made to the JIRA issue tracker to have this fixed with a global variable for a future release. |
|
You may need to upgrade to DBUnit2.2 for this to work. Don't forget to update your lib.properties : |
|
{{{ |
# |
# DBUnit - http://www.dbunit.org/ |
# |
dbunit.version=2.2 |
dbunit.dir=${lib.dir}/dbunit-${dbunit.version} |
dbunit.jar=${dbunit.dir}/dbunit-${dbunit.version}.jar |
}}} |