From open-jpa-dev-return-1303-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Mon Dec 04 20:13:23 2006 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 89924 invoked from network); 4 Dec 2006 20:13:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2006 20:13:23 -0000 Received: (qmail 96270 invoked by uid 500); 4 Dec 2006 20:13:31 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 96246 invoked by uid 500); 4 Dec 2006 20:13:31 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 96237 invoked by uid 99); 4 Dec 2006 20:13:31 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2006 12:13:31 -0800 X-ASF-Spam-Status: No, hits=2.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ghongell@us.ibm.com designates 32.97.110.151 as permitted sender) Received: from [32.97.110.151] (HELO e33.co.us.ibm.com) (32.97.110.151) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2006 12:13:18 -0800 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e33.co.us.ibm.com (8.13.8/8.12.11) with ESMTP id kB4KCuM8028760 for ; Mon, 4 Dec 2006 15:12:56 -0500 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by westrelay02.boulder.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id kB4KCu33539802 for ; Mon, 4 Dec 2006 13:12:56 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id kB4KCuwR011056 for ; Mon, 4 Dec 2006 13:12:56 -0700 Received: from d03nm131.boulder.ibm.com (d03nm131.boulder.ibm.com [9.17.195.171]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id kB4KCuoV011038 for ; Mon, 4 Dec 2006 13:12:56 -0700 In-Reply-To: <7D856CDFE035FF45A0420ACBD71BDD6302939274@repbex02.amer.bea.com> To: "Patrick Linskey" Cc: Ahmad Nouri , David Wisneski , open-jpa-dev@incubator.apache.org Subject: RE: openjpa NativeQuery and NamedNativeQuery only allow select sql statements MIME-Version: 1.0 X-Mailer: Lotus Notes Release 7.0 HF144 February 01, 2006 Message-ID: From: George Hongell Date: Mon, 4 Dec 2006 12:12:54 -0800 X-MIMETrack: Serialize by Router on D03NM131/03/M/IBM(Release 7.0.2HF32 | October 17, 2006) at 12/04/2006 13:12:55, Serialize complete at 12/04/2006 13:12:55 Content-Type: multipart/alternative; boundary="=_alternative 006F0D248825723A_=" X-Virus-Checked: Checked by ClamAV on apache.org --=_alternative 006F0D248825723A_= Content-Type: text/plain; charset="US-ASCII" Hi Patrick, I am using Query.executeUpdate()for all but the queries where I am trying to call a stored procedure where what execute I use depends on whether the stored procedure returns a result set. Here is my "insert" example. String name = "insert into DeptBean (deptno) values (?)"; Query q1 = _em.createNativeQuery(name); q1.setParameter(1,200); int inserted = q1.executeUpdate (); <4|false|0.0.0> org.apache.openjpa.persistence.InvalidStateException: Cannot perform an update or delete operation on select query: "insert into DeptBean (deptno) values (?)". at org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:306) at com.ibm.ws.query.tests.JUNamedNativeQueryTest.testInsertQuery(JUNamedNativeQueryTest.java:315) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at junit.framework.TestCase.runTest(Unknown Source) at junit.framework.TestCase.runBare(Unknown Source) at junit.framework.TestResult$1.protect(Unknown Source) at junit.framework.TestResult.runProtected(Unknown Source) Here is my "update" example. String name = "nativeUpdateDeptBudget"; Query q1 = _em.createNamedQuery(name); q1.setParameter(1,10000); int updated = q1.executeUpdate (); <4|false|0.0.0> org.apache.openjpa.persistence.InvalidStateException: Cannot perform an update or delete operation on select query: "update DeptBean d set d.budget = (d.budget + ?1)". at org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:306) at com.ibm.ws.query.tests.JUNamedNativeQueryTest.testUpdateDeptBudget(JUNamedNativeQueryTest.java:367) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:615) at junit.framework.TestCase.runTest(Unknown Source) at junit.framework.TestCase.runBare(Unknown Source) at junit.framework.TestResult$1.protect(Unknown Source) at junit.framework.TestResult.runProtected(Unknown Source) at junit.framework.TestResult.run(Unknown Source) at junit.framework.TestCase.run(Unknown Source) at junit.framework.TestSuite.runTest(Unknown Source) at junit.framework.TestSuite.run(Unknown Source) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) "Patrick Linskey" 12/04/2006 10:21 AM To , George Hongell/Santa Teresa/IBM@IBMUS cc David Wisneski/Santa Teresa/IBM@IBMUS, Ahmad Nouri/Santa Teresa/IBM@IBMUS Subject RE: openjpa NativeQuery and NamedNativeQuery only allow select sql statements Hi, How are you executing the query? I'm guessing that you're using Query.getResultList() or Query.getSingleResult() instead of Query.executeUpdate(). -Patrick -- Patrick Linskey BEA Systems, Inc. _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. > -----Original Message----- > From: George Hongell [mailto:ghongell@us.ibm.com] > Sent: Monday, December 04, 2006 10:12 AM > To: open-jpa-dev@incubator.apache.org > Cc: David Wisneski; Ahmad Nouri > Subject: openjpa NativeQuery and NamedNativeQuery only allow > select sql statements > > It seems that openjpa NativeQuery and NamedNativeQuery only > allow "select" > sql statements. When I try to > insert, delete, update, create table, alter table, drop > table, or call a > stored procedure, I get > <4|false|0.9.6-incubating-SNAPSHOT> > org.apache.openjpa.persistence.InvalidStateException: Cannot > perform an > update or delete operation on select query: "call out2(?, ?)". > Is this intentional? > I expected the NativeQuery to allow me to execute any valid > sql statement. > --=_alternative 006F0D248825723A_=--