db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Rall <...@finemaltcoding.com>
Subject Re: HSQLDB primary key generation
Date Thu, 10 Jul 2003 22:42:52 GMT
Anyone look into Mike's suggestion yet?

"Mike Pearce" <mike@studioelectrica.com> writes:

> Hello.
> 
> I am using Torque with OJB and came across a bug when generating a SQL
> script for HSQL.  If the schema xml file has a column tag with both
> primaryKey and autoIncrement attributes, it generates incorrect HSQL create
> table syntax.  The latest version (and probably other versions) of HSQL does
> not appear to allow having a column specified as "IDENTITY" and setting that
> same column as "PRIMARY KEY".  According to the HSQL documentation, identity
> columns are "automatically primary key columns."
> 
> NOT CORRECT:
> CREATE TABLE Product
> (
>     id integer IDENTITY,
>     name VARCHAR (30),
>     price DOUBLE,
>     stock integer,
>     PRIMARY KEY(id)
> );
> 
> 
> CORRECT:
> CREATE TABLE Product
> (
>     id integer IDENTITY,
>     name VARCHAR (30),
>     price DOUBLE,
>     stock integer
> );
> 
> 
> I modified the primarykey.vm to work when both of these attributes are
> specified:
> 
> /sql/base/hypersonic/primarykey.vm
> ----------------------------------------------------------------------------
> -------
> #if ($table.hasPrimaryKey())
> #set ( $hasAutoIncrement = "false" )
> #foreach ($col in $table.Columns)
> #if ( $col.isAutoIncrement() )
> #set ( $hasAutoIncrement = "true" )
> #end
> #end
> #if ( $hasAutoIncrement == "false" )
> PRIMARY KEY($table.printPrimaryKey()),
> #end
> #end
> 
> -mike
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
> 

-- 

Daniel Rall

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message