db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Carl <patrick.c...@web.de>
Subject Re: [PATCH] Torque with hsqldb and referenced identity columns
Date Wed, 23 Nov 2005 06:20:12 GMT
Hi,

my submitted patch broke the generated sql for hypersonic. After I was 
able to run the test project I found it out.

But I was able to get it to work again, here's the patch description:

Using hsqldb with id-method native columns creates columns defined with 
the constraint "IDENTITY". This generated an index starting with 0. As 
Torque regards objects with an primary key 0 as not initialized, this 
can lead to problems when using relationships between tables. To prevent 
this I've patched the generated string from "IDENTITY" to "GENERATED BY 
DEFAULT AS IDENTITY (STARTING WITH 0)". This broke the created SQL for 
hsqldb tables since Torque preprends the String "NOT NULL" in front of 
the identity string. hsqldb does not allow this. To change this I've 
patched the interface org.apache.torque.engine.platform.Platform and 
added a method "public getNullString(Column col)" since the 
PlatformHypersonicImpl needed to know if the column is a not null and if 
the column uses the native id-method. The default implementation of 
Platform delegates the call of this method to the former existing one. 
Only the hsqldb implementation uses more than the property notNull of 
the column. The new method is now used getSqlString of class Column.

Please find the patch files attached.

Cheers, Patrick

Patrick Carl schrieb:
> Hello there,
> 
> when using Torque with hsqldb adn native id generation Torque uses the 
> column constraint "IDENTITY" of hsqldb. This creates by default primary 
> key ids starting with 0. This can lead to false behaviour in the 
> following conditions:
> It is possible that an object A with id 0 is created. If this object is 
> refered by an related object B, the method B.getA does not work, since 
> B.getA checks if B.aId != 0.
> 
> To prevent this I created the attached patches. Using them will set the 
> starting id of an identity column to 1.
> 
> Please note that I wasn't abled to get the test project to work, so I 
> couldn't test this patch as much as I would. Perhaps someone else can do 
> this.
> 
> Patrick
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> 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