Return-Path: Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 75378 invoked by uid 500); 8 Jul 2003 09:23:49 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Turbine Torque Developers List" Reply-To: "Turbine Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 75367 invoked from network); 8 Jul 2003 09:23:49 -0000 Received: from chorgh.serverconfig.com (162.42.208.249) by daedalus.apache.org with SMTP; 8 Jul 2003 09:23:49 -0000 Received: from adsl-63-196-4-147.dsl.snfc21.pacbell.net ([63.196.4.147] helo=mpearce) by chorgh.serverconfig.com with smtp (Exim 4.20) id 19Zohf-00031b-17 for torque-dev@db.apache.org; Tue, 08 Jul 2003 05:24:03 -0400 Message-ID: <015401c34532$c60e1980$0200a8c0@mpearce> From: "Mike Pearce" To: References: <1057655462.51250.ezmlm@db.apache.org> Subject: HSQLDB primary key generation Date: Tue, 8 Jul 2003 02:24:46 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - chorgh.serverconfig.com X-AntiAbuse: Original Domain - db.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - studioelectrica.com X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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