Hi Guys,

For anyone interested, I've been able to get OJB 1.0.0, Torque-Gen 3.1
and HSQLDB 1.7.2 working together.

Torque 3.1 seems to work out of the box with OJB 1.0.0, but not with the
OJB JUnit tests because Torque 3.1 doesn't like the schema files used
for these tests. I've created some new schema files that seem to work OK
(linked to below).

HSQLDB 1.7.2 has problems with Torque because databases created using
HSQLDB's "In-Process" mode (as the standard DB is in the OJB JUnit
tests) must now be explicitly closed with a "SHUTDOWN" command for other
processes to use them. I've contacted the HSQLDB guys about a way to do
this using SQL, so that it could be included in Torque's template files,
but for now I've settled on patching the build-torque.xml file to do
this during the build process, if necessary.

HSQLDB 1.7.2 also has problems with one of OJB's testcases that uses
hardcoded SQL commands, specifically
org.apache.ojb.broker.sequence.NativeIdentifierTest as the syntax used
in this file is not allowed.

So, here are the steps to get Torque 3.1 working with OJB 1.0.0:

- Download OJB 1.0.0 from:
http://db.apache.org/builds/ojb/1.0.0/db-ojb-1.0.0-src.zip
and unpack the db-ojb-1.0.0 dir.

- Download torque-gen-3.1 from:
http://db.apache.org/builds/torque/release/3.1/torque-gen-3.1.zip
and unpack the torque-gen-3.1 dir.

- Remove old db-ojb-1.0.0/lib/torque-3.0.2.jar

- Copy torque-gen-3.1.jar and village-2.0-dev-20030825.jar from
torque-gen-3.1/lib/ to db-ojb-1.0.0/lib/

- Replace db-ojb-1.0.0/build-torque.xml with torque-gen-3.1/build-torque.xml

- Copy over
http://www.alphalink.com.au/~mwhart/ojb/ojbtest-data.dtd and
http://www.alphalink.com.au/~mwhart/ojb/ojbtest-data.xml
to db-ojb-1.0.0/src/schema/

- Grab copies of j2ee.jar and jdo.jar if you don't already have them and
copy them to db-ojb-1.0.0/lib/

- Make sure junit.jar is in $ANT_HOME/lib/ and then run "ant junit" from the db-ojb-1.0.0 dir
(ignore the SQL error when trying to create the DB - you can get rid of this by removing the "ECHO Not implemented" on the first line of sql/db-init/hypersonic/createdb.vm in torque-gen-3.1.jar - and also ignore the log4j ERROR messages - you can get rid of these by removing the ", org.apache.torque.engine" at the end of line 15 of log4j.properties in torque-gen-3.1.jar)


With any luck, all tests will pass!

Now, to get HSQLDB 1.7.2 working with OJB 1.0.0 (assuming previous steps
have been done):

- Download HSQLDB 1.7.2 from
http://prdownloads.sourceforge.net/hsqldb/hsqldb_1_7_2_3.zip?download
and unpack the hsqldb dir.

- Replace db-ojb-1.0.0/lib/hsqldb.jar with new hsqldb/lib/hsqldb.jar

- Replace
db-ojb-1.0.0/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java


with http://www.alphalink.com.au/~mwhart/ojb/NativeIdentifierTest.java
(diff below)

- If you want to support the new sequences in HSQLDB 1.7.2, replace
db-ojb-1.0.0/src/java/org/apache/ojb/broker/platforms/PlatformHsqldbImpl.java


with http://www.alphalink.com.au/~mwhart/ojb/PlatformHsqldbImpl.java
(diff below)

- Replace db-ojb-1.0.0/build-torque.xml with
http://www.alphalink.com.au/~mwhart/ojb/build-torque.xml (diff below)

- Run "ant junit" from the db-ojb-1.0.0 dir

Hopefully, all tests will pass again!

There are probably quite a few more changes introduced in HSQLDB 1.7.2
that could be updated in OJB, but sequences was all I was interested in
and they seem to work fine so far.

Cheers,

Michael

P.S.

Here are the diffs for those interested (sorry if it wraps):

diff for NativeIdentifierTest.java:

48c48
<             " REF_ID int(11),NAME VARCHAR(250))";
---
" REF_ID INT, NAME VARCHAR(250))";
58c58
< " NAME VARCHAR(250), FK_ID BIGINT, REF_ID int(11), SINGLE_REF_FK BIGINT)";
---
" NAME VARCHAR(250), FK_ID BIGINT, REF_ID INT, SINGLE_REF_FK BIGINT)";


diff for PlatformHsqldbImpl.java:

67a68,81
    public String createSequenceQuery(String sequenceName)
    {
        return "CREATE SEQUENCE " + sequenceName;
    }

    public String nextSequenceQuery(String sequenceName)
    {
        return "CALL NEXT VALUE FOR " + sequenceName;
    }

    public String dropSequenceQuery(String sequenceName)
    {
        return "DROP SEQUENCE " + sequenceName;
    }



$ diff for build-torque.xml (based on the file found in torque-gen-3.1, not OJB):

249a250,318
> <!-- S H U T D O W N C H E C K -->
> <!-- ================================================================ -->
> <!-- Hack to check if we need to shutdown the DB after we're done -->
> <!-- using it. At the moment, the only DB which this must be done for -->
> <!-- is HSQLDB when running in the "In-Process" mode. -->
> <!-- As this mode can be specified without a keyword, we just check -->
> <!-- that the JDBC URL (specified in the dbUrlToCheck property) is -->
> <!-- an HSQLDB URL, but not one of the other modes. -->
> <!-- ================================================================ -->
>
> <target name="shutdown-check">
> <condition property="torque.internal.shutdownAfterSql">
> <and>
> <contains string="${dbUrlToCheck}" substring="jdbc:hsqldb" />
> <not>
> <or>
> <contains string="${dbUrlToCheck}"
> substring="jdbc:hsqldb:hsql://" />
> <contains string="${dbUrlToCheck}"
> substring="jdbc:hsqldb:hsqls://" />
> <contains string="${dbUrlToCheck}"
> substring="jdbc:hsqldb:http://"; />
> <contains string="${dbUrlToCheck}"
> substring="jdbc:hsqldb:https://"; />
> </or>
> </not>
> </and>
> </condition>
> </target>
>
> <!-- ================================================================ -->
> <!-- A P P E N D S H U T D O W N S Q L -->
> <!-- ================================================================ -->
> <!-- Appends a SHUTDOWN statement to the file specified in the -->
> <!-- shutdownAppendFile property after first checking that it's -->
> <!-- necessary using the shutdown-check task. -->
> <!-- ================================================================ -->
>
> <target name="append-shutdown-sql"
> depends="shutdown-check"
> if="torque.internal.shutdownAfterSql">
>
> <echo file="${shutdownAppendFile}" append="true">;
> SHUTDOWN;
> </echo>
>
> </target>
>
> <!-- ================================================================ -->
> <!-- A D D S H U T D O W N S Q L F I L E -->
> <!-- ================================================================ -->
> <!-- Adds a shutdown.sql file to the sql dir with a SHUTDOWN -->
> <!-- statement in it and also adds this file to sqldb.map after first -->
> <!-- checking that it's necessary using the shutdown-check task. -->
> <!-- ================================================================ -->
>
> <target name="add-shutdown-sql-file"
> depends="shutdown-check"
> if="torque.internal.shutdownAfterSql">
>
> <echo file="${torque.sql.dir}/shutdown.sql"
> message="SHUTDOWN;" />
>
> <echo file="${torque.sql.dir}/sqldb.map" append="true"
> message="shutdown.sql=${torque.project}" />
>
> </target>
>
> <!-- ================================================================ -->
280a350,357
> <!-- Append the SHUTDOWN statement if need be -->
> <antcall target="append-shutdown-sql">
> <param name="dbUrlToCheck"
> value="${torque.database.createUrl}" />
> <param name="shutdownAppendFile"
> value="${torque.sql.dir}/create-db.sql" />
> </antcall>
>
294a372
>
304a383,388
> <!-- Add the shutdown.sql file if need be -->
> <antcall target="add-shutdown-sql-file">
> <param name="dbUrlToCheck"
> value="${torque.database.buildUrl}" />
> </antcall>
>
315a400
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to