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
Index:
src/test/org/apache/torque/engine/database/model/HypersonicDomainTest.java
===================================================================
--- src/test/org/apache/torque/engine/database/model/HypersonicDomainTest.java
(Revision 345330)
+++ src/test/org/apache/torque/engine/database/model/HypersonicDomainTest.java
(Arbeitskopie)
@@ -113,8 +113,8 @@
{
Table table = db.getTable("native");
Column col = table.getColumn("native_id");
- assertEquals("IDENTITY", col.getAutoIncrementString());
- assertEquals("native_id INTEGER NOT NULL IDENTITY",
col.getSqlString());
+ assertEquals("GENERATED BY DEFAULT AS IDENTITY START WITH 1",
col.getAutoIncrementString());
+ assertEquals("native_id INTEGER NOT NULL GENERATED BY DEFAULT AS
IDENTITY START WITH 1", col.getSqlString());
col = table.getColumn("name");
assertEquals("", col.getAutoIncrementString());
}
Index: src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java
===================================================================
--- src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java
(Revision 345330)
+++ src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java
(Arbeitskopie)
@@ -47,6 +47,11 @@
setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BINARY"));
setSchemaDomainMapping(new Domain(SchemaType.BLOB, "BINARY"));
setSchemaDomainMapping(new Domain(SchemaType.CLOB, "LONGVARCHAR"));
- }
+ }
+
+ public String getAutoIncrement()
+ {
+ return "GENERATED BY DEFAULT AS IDENTITY START WITH 1";
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]