db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Owens" <j...@payrollnw.com>
Subject Torque 3 Hypersonic Autoincrement question
Date Mon, 12 May 2003 23:34:56 GMT
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.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message