From open-jpa-dev-return-717-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Mon Sep 18 16:46:01 2006 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 3597 invoked from network); 18 Sep 2006 16:46:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Sep 2006 16:46:01 -0000 Received: (qmail 76112 invoked by uid 500); 18 Sep 2006 16:46:00 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 76089 invoked by uid 500); 18 Sep 2006 16:46:00 -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 76079 invoked by uid 99); 18 Sep 2006 16:46:00 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Sep 2006 09:46:00 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mprudhomapache@gmail.com designates 64.233.184.239 as permitted sender) Received: from [64.233.184.239] (HELO wr-out-0506.google.com) (64.233.184.239) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Sep 2006 09:45:56 -0700 Received: by wr-out-0506.google.com with SMTP id 58so1473836wri for ; Mon, 18 Sep 2006 09:45:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=WK8nVhfHvzRn63EmUnpB+a9hB71dWHDtzZYMLnPYHBTrfiUKyyzrGXiZnYlvTGqmdIDI0MqLxpscdySxtQVdUUFAlCJ49iAM60MBFZx4me9kgVMBsVN1l8UgBfSoyQTYIRin//aKrMkm307l7srg+5s+V9B6R19JMaXcwG5WBCI= Received: by 10.90.34.9 with SMTP id h9mr554353agh; Mon, 18 Sep 2006 09:45:35 -0700 (PDT) Received: from ?192.168.1.3? ( [66.248.222.242]) by mx.gmail.com with ESMTP id 12sm3224816nzn.2006.09.18.09.45.34; Mon, 18 Sep 2006 09:45:35 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <89c0c52c0609180937n55bd7b0ch54fc38a7ebee7690@mail.gmail.com> References: <89c0c52c0609180937n55bd7b0ch54fc38a7ebee7690@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <531BE952-B5CF-470D-94FF-5C9FDB5ACFA4@apache.org> Content-Transfer-Encoding: 7bit From: Marc Prud'hommeaux Subject: Re: Does OpenJPA support updating of related objects via JPQL? Date: Mon, 18 Sep 2006 09:45:12 -0700 To: open-jpa-dev@incubator.apache.org X-Mailer: Apple Mail (2.752.2) Sender: Marc Prud'hommeaux X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Kevin- The only thing that can be updated in a bulk update statement is a field in the Entity that is the subject of the UPDATE statement without any traversals, as per: 4.10 Bulk Update and Delete Operations Bulk update and delete operations apply to entities of a single entity class (together with its subclasses, if any). Only one entity abstract schema type may be specified in the FROM or UPDATE clause. The syntax of these operations is as follows: update_statement ::= update_clause [where_clause] update_clause ::= UPDATE abstract_schema_name [[AS] identification_variable] SET update_item {, update_item}* update_item ::= [identification_variable.]{state_field | single_valued_association_field} = new_value On Sep 18, 2006, at 9:37 AM, Kevin Sutter wrote: > Hi, > Does OpenJPA (or JPA, for tha matter) support the updating of related > objects via JPQL? For example, should the following query work > where we are > attempting to access the orderId on the related currentOrder object? > > UPDATE Customer c SET c.currentOrder.orderId = :orderId WHERE c.id = > :customerId > > As you can guess, we are getting an exception and call stack from > OpenJPA. > But, then we started wondering whether this is even supported by > the JPA > spec. The spec isn't clear one way or the other (or, at least, I > couldn't > find a definitive answer). Any ideas? > > In case you were wondering, here's the call stack: > > [9/16/06 16:15:52:953 EDT] 00000032 ExceptionUtil E CNTR0020E: > EJB threw > an unexpected (non-declared) exception during invocation of method > "openOrder" on bean "BeanId > (OpenJPATestEAR#OpenJPATest.jar#OrderEJB, null)". > Exception data: <4|false|0.9.0-incubating-SNAPSHOT> > org.apache.openjpa.persistence.ArgumentException: An error occurred > while > parsing the query filter 'UPDATE Customer c SET > c.currentOrder.orderId = > :orderId WHERE c.id = :customerId'. Error message: > <4|false|0.9.0-incubating-SNAPSHOT> > org.apache.openjpa.kernel.jpql.ParseException: Encountered "." at > character > 37, but expected: ["="]. > at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder > $ParsedJPQL.parse > (JPQLExpressionBuilder.java:1655) > at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL > .(JPQLExpressionBuilder.java:1638) > at org.apache.openjpa.kernel.jpql.JPQLParser.parse > (JPQLParser.java:44) > at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation( > ExpressionStoreQuery.java:141) > at org.apache.openjpa.kernel.QueryImpl.newCompilation > (QueryImpl.java > :598) > at org.apache.openjpa.kernel.QueryImpl.compileForCompilation( > QueryImpl.java:581) > at org.apache.openjpa.kernel.QueryImpl.compileForExecutor > (QueryImpl.java > :608) > at org.apache.openjpa.kernel.QueryImpl.getOperation > (QueryImpl.java:1421) > at org.apache.openjpa.kernel.DelegatingQuery.getOperation( > DelegatingQuery.java:120) > at org.apache.openjpa.persistence.QueryImpl.executeUpdate > (QueryImpl.java > :293) > : > : > > Thanks, > Kevin