You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Jeff Owens <je...@payrollnw.com> on 2003/05/13 01:34:56 UTC

Torque 3 Hypersonic Autoincrement question

Using Torque 3.0
Hypersonic - hsqldb.jar 1.7.1

Problem:
When I attempt to add new records to a table: Instead of null for the auto incremented primary key, Torque is supplying a 0 (zero) integer value.  For example, What I get: insert into test(clientkey,somefield) values(0,"somedata").  What I want: insert into test(clientkey,somefield) values(null,"somedata").  Obviously, the first case (what I'm getting) causes an exception on the 2nd new record.

Question:  Can anyone tell me how to have an auto-incremented primary key in hypersonic work correctly?

Details:
I've managed to get auto-increment working in hsqldb (Hypersonic) by using autoIncrement="true" and type="INTEGER" like so:
<table name="test" idMethod="native">
<column name="CLIENTKEY" autoIncrement="true" type="INTEGER"/>

This works to create a sql source command like so:
CREATE TABLE TEST
(
    CLIENTKEY integer IDENTITY,
    ...
    ...
);

Which correctly creates an auto-incremented Primary Key field "CLIENTKEY".  Unfortunately, even though this is not a required field, Torque is supplying a value - 0 (zero) - which causes an exception when I try adding another record.

Originally I had the column setup as:
<column name="CLIENTKEY" required="true" primaryKey="true" type="INTEGER"/>
I had to remove the primaryKey="true" because setting a field to be IDENTITY - in hsqldb - causes it to be a primary key by default.