cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r504923 - in /cayenne/main/branches/STABLE-1.2/cayenne: cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/ cayenne-java/src/cayenne/java/org/objectstyle/cay...
Date Thu, 08 Feb 2007 15:10:44 GMT
Author: aadamchik
Date: Thu Feb  8 07:10:41 2007
New Revision: 504923

URL: http://svn.apache.org/viewvc?view=rev&rev=504923
Log:
CAY-750 Stored procedures without parameters fail on Postgres 8 (1.2 branch fix)

Modified:
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ProcedureAction.java
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/PostgresProcedureAction.java
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/sqlserver/SQLServerProcedureAction.java
    cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ProcedureAction.java?view=diff&rev=504923&r1=504922&r2=504923
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ProcedureAction.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/jdbc/ProcedureAction.java
Thu Feb  8 07:10:41 2007
@@ -161,12 +161,12 @@
      * @param connection JDBC connection
      */
     protected ProcedureTranslator createTranslator(Connection connection) {
-        ProcedureTranslator transl = new ProcedureTranslator();
-        transl.setAdapter(getAdapter());
-        transl.setQuery(query);
-        transl.setEntityResolver(getEntityResolver());
-        transl.setConnection(connection);
-        return transl;
+        ProcedureTranslator translator = new ProcedureTranslator();
+        translator.setAdapter(getAdapter());
+        translator.setQuery(query);
+        translator.setEntityResolver(getEntityResolver());
+        translator.setConnection(connection);
+        return translator;
     }
 
     /**

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/PostgresProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/PostgresProcedureAction.java?view=diff&rev=504923&r1=504922&r2=504923
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/PostgresProcedureAction.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/postgres/PostgresProcedureAction.java
Thu Feb  8 07:10:41 2007
@@ -55,6 +55,9 @@
  */
 package org.objectstyle.cayenne.dba.postgres;
 
+import java.sql.Connection;
+
+import org.objectstyle.cayenne.access.trans.ProcedureTranslator;
 import org.objectstyle.cayenne.dba.DbAdapter;
 import org.objectstyle.cayenne.dba.sqlserver.SQLServerProcedureAction;
 import org.objectstyle.cayenne.map.EntityResolver;
@@ -74,5 +77,33 @@
     PostgresProcedureAction(ProcedureQuery query, DbAdapter adapter,
             EntityResolver entityResolver) {
         super(query, adapter, entityResolver);
+    }
+
+    /**
+     * Creates a translator that adds parenthesis to no-param queries.
+     */
+    // see CAY-750 for the problem description
+    protected ProcedureTranslator createTranslator(Connection connection) {
+        ProcedureTranslator translator = new PostgresProcedureTranslator();
+        translator.setAdapter(getAdapter());
+        translator.setQuery(query);
+        translator.setEntityResolver(getEntityResolver());
+        translator.setConnection(connection);
+        return translator;
+    }
+
+    static class PostgresProcedureTranslator extends ProcedureTranslator {
+
+        protected String createSqlString() {
+
+            String sql = super.createSqlString();
+
+            // add empty parameter parenthesis
+            if (sql.endsWith("}") && !sql.endsWith(")}")) {
+                sql = sql.substring(0, sql.length() - 1) + "()}";
+            }
+
+            return sql;
+        }
     }
 }

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/sqlserver/SQLServerProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/sqlserver/SQLServerProcedureAction.java?view=diff&rev=504923&r1=504922&r2=504923
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/sqlserver/SQLServerProcedureAction.java
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/dba/sqlserver/SQLServerProcedureAction.java
Thu Feb  8 07:10:41 2007
@@ -96,12 +96,7 @@
     public void performAction(Connection connection, OperationObserver observer)
             throws SQLException, Exception {
 
-        ProcedureTranslator transl = new ProcedureTranslator();
-        transl.setAdapter(getAdapter());
-        transl.setQuery(query);
-        transl.setEntityResolver(this.getEntityResolver());
-        transl.setConnection(connection);
-
+        ProcedureTranslator transl = createTranslator(connection);
         CallableStatement statement = (CallableStatement) transl.createStatement();
 
         try {

Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt?view=diff&rev=504923&r1=504922&r2=504923
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
(original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
Thu Feb  8 07:10:41 2007
@@ -10,3 +10,4 @@
 
 Bug Fixes:
 
+CAY-750 Stored procedures without parameters fail on Postgres 8



Mime
View raw message