db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject PostgreSQL and SequenceIdGenerator
Date Tue, 14 Oct 2003 00:27:36 GMT
It strikes me as odd that intenrally Torque uses AUTO_INCREMENT as the 
IDMethodType for PostgreSQL.  Wouldn't SEQUENCE be more appropriate?  
The patch below implements this, but I don't want to commit it without 
review since it seems such an obvious thing that there must be a reason 
for it.  It looks to me like the code will actually have to stay as it 
is because the patch would impact other DB adapters that use SEQUENCE 
(e.g. Oracle).  The conclusion seems to be that the IDMethodTypes and 
IdGenerators are poorly named (most likely for historical reasons) and 
something like Pre/PostInsertIdGenerator would be more appropriate.

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au


Index: org/apache/torque/adapter/DBPostgres.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/adapter/DBPostgres.java,v
retrieving revision 1.16
diff -u -r1.16 DBPostgres.java
--- org/apache/torque/adapter/DBPostgres.java	25 Aug 2003 21:56:10 -0000	1.16
+++ org/apache/torque/adapter/DBPostgres.java	14 Oct 2003 00:18:03 -0000
@@ -103,7 +103,7 @@
      */
     public String getIDMethodType()
     {
-        return AUTO_INCREMENT;
+        return SEQUENCE;
     }
 
     /**
Index: org/apache/torque/oid/SequenceIdGenerator.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/oid/SequenceIdGenerator.java,v
retrieving revision 1.10
diff -u -r1.10 SequenceIdGenerator.java
--- org/apache/torque/oid/SequenceIdGenerator.java	25 Aug 2003 16:33:22 -0000	1.10
+++ org/apache/torque/oid/SequenceIdGenerator.java	14 Oct 2003 00:18:05 -0000
@@ -154,7 +154,7 @@
      */
     public boolean isPriorToInsert()
     {
-        return true;
+        return false;
     }
 
     /**
@@ -164,7 +164,7 @@
      */
     public boolean isPostInsert()
     {
-        return false;
+        return true;
     }
 
     /**





---------------------------------------------------------------------
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