cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r504906 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test: java/org/apache/cayenne/access/ java/org/apache/cayenne/unit/ resources/ resources/ddl/postgresql/
Date Thu, 08 Feb 2007 14:22:18 GMT
Author: aadamchik
Date: Thu Feb  8 06:22:17 2007
New Revision: 504906

URL: http://svn.apache.org/viewvc?view=rev&rev=504906
Log:
CAY-750 Stored procedures without parameters fail on Postgres 8
(unit tests to reproduce the problem)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/ddl/postgresql/create-update-sp2.sql
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/PostgresStackAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/testmap.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java?view=diff&rev=504906&r1=504905&r2=504906
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
Thu Feb  8 06:22:17 2007
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access;
 
 import java.math.BigDecimal;
@@ -43,6 +42,7 @@
 public class DataContextProcedureQueryTest extends CayenneCase {
 
     public static final String UPDATE_STORED_PROCEDURE = "cayenne_tst_upd_proc";
+    public static final String UPDATE_STORED_PROCEDURE_NOPARAM = "cayenne_tst_upd_proc2";
     public static final String SELECT_STORED_PROCEDURE = "cayenne_tst_select_proc";
     public static final String OUT_STORED_PROCEDURE = "cayenne_tst_out_proc";
 
@@ -71,6 +71,43 @@
 
         ProcedureQuery q = new ProcedureQuery(UPDATE_STORED_PROCEDURE);
         q.addParameter("paintingPrice", new Integer(3000));
+
+        // since stored procedure commits its stuff, we must use an explicit
+        // non-committing transaction
+
+        Transaction t = Transaction.externalTransaction(null);
+        Transaction.bindThreadTransaction(t);
+
+        try {
+            ctxt.performGenericQuery(q);
+        }
+        finally {
+            Transaction.bindThreadTransaction(null);
+            t.commit();
+        }
+
+        // check that price have doubled
+        SelectQuery select = new SelectQuery(Artist.class);
+        select.addPrefetch("paintingArray");
+
+        List artists = ctxt.performQuery(select);
+        assertEquals(1, artists.size());
+
+        Artist a = (Artist) artists.get(0);
+        Painting p = (Painting) a.getPaintingArray().get(0);
+        assertEquals(2000, p.getEstimatedPrice().intValue());
+    }
+
+    public void testUpdateNoParam() throws Exception {
+        // Don't run this on MySQL
+        if (!getAccessStackAdapter().supportsStoredProcedures()) {
+            return;
+        }
+
+        // create an artist with painting in the database
+        createArtist(1000.0);
+
+        ProcedureQuery q = new ProcedureQuery(UPDATE_STORED_PROCEDURE_NOPARAM);
 
         // since stored procedure commits its stuff, we must use an explicit
         // non-committing transaction

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/PostgresStackAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/PostgresStackAdapter.java?view=diff&rev=504906&r1=504905&r2=504906
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/PostgresStackAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/PostgresStackAdapter.java
Thu Feb  8 06:22:17 2007
@@ -60,6 +60,7 @@
         if (map.getProcedureMap().containsKey("cayenne_tst_select_proc")) {
             executeDDL(con, "postgresql", "create-select-sp.sql");
             executeDDL(con, "postgresql", "create-update-sp.sql");
+            executeDDL(con, "postgresql", "create-update-sp2.sql");
             executeDDL(con, "postgresql", "create-out-sp.sql");
         }
     }

Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/ddl/postgresql/create-update-sp2.sql
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/ddl/postgresql/create-update-sp2.sql?view=auto&rev=504906
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/ddl/postgresql/create-update-sp2.sql
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/ddl/postgresql/create-update-sp2.sql
Thu Feb  8 06:22:17 2007
@@ -0,0 +1,4 @@
+ CREATE OR REPLACE FUNCTION cayenne_tst_upd_proc2 () RETURNS VOID
+ AS '
+        UPDATE PAINTING SET ESTIMATED_PRICE = ESTIMATED_PRICE * 2;
+ ' LANGUAGE SQL;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/testmap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/testmap.map.xml?view=diff&rev=504906&r1=504905&r2=504906
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/testmap.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/resources/testmap.map.xml
Thu Feb  8 06:22:17 2007
@@ -12,6 +12,8 @@
 	<procedure name="cayenne_tst_upd_proc">
 		<procedure-parameter name="paintingPrice" type="INTEGER" direction="in"/>
 	</procedure>
+	<procedure name="cayenne_tst_upd_proc2">
+	</procedure>
 	<db-entity name="ARRAYS_ENTITY">
 		<db-attribute name="BYTE_ARRAY" type="VARBINARY" length="200"/>
 		<db-attribute name="BYTE_WRAPPER_ARRAY" type="VARBINARY" length="200"/>



Mime
View raw message