Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 4198 invoked from network); 18 Sep 2006 21:42:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Sep 2006 21:42:42 -0000 Received: (qmail 5392 invoked by uid 500); 18 Sep 2006 21:42:42 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 5305 invoked by uid 500); 18 Sep 2006 21:42:41 -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 5296 invoked by uid 99); 18 Sep 2006 21:42:41 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Sep 2006 14:42:41 -0700 Authentication-Results: idunn.apache.osuosl.org header.from=kwsutter@gmail.com; domainkeys=good X-ASF-Spam-Status: No, hits=0.9 required=5.0 tests=DNS_FROM_RFC_ABUSE,HTML_20_30,HTML_MESSAGE,RCVD_BY_IP DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 Received: from ([66.249.82.229:32186] helo=wx-out-0506.google.com) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 7F/63-22826-9C21F054 for ; Mon, 18 Sep 2006 14:42:34 -0700 Received: by wx-out-0506.google.com with SMTP id s13so4080138wxc for ; Mon, 18 Sep 2006 14:42:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=EjzUwF7tKxWJ/uQ3jdef/UTM1S5vOuNp9QSm09si1fMV+SJ340EJ8MUYneylhpu+l5UHpowt2jb797W/9XxyMZEX17nssjgTvvPG0oI4Auw2k4wvLmeQJVLTkq+S9AxPrs4aLooSBprZ6kJH82dJ8hSWrcrbmT0J5O/NLPM24mU= Received: by 10.90.29.15 with SMTP id c15mr887123agc; Mon, 18 Sep 2006 14:29:24 -0700 (PDT) Received: by 10.90.100.12 with HTTP; Mon, 18 Sep 2006 14:29:24 -0700 (PDT) Message-ID: <89c0c52c0609181429v215f6467w77a2cabffae7607d@mail.gmail.com> Date: Mon, 18 Sep 2006 16:29:24 -0500 From: "Kevin Sutter" To: open-jpa-dev@incubator.apache.org Subject: Re: Does OpenJPA support updating of related objects via JPQL? In-Reply-To: <690511EF-0349-4323-87C4-124C579DB1D8@apache.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_75191_30886231.1158614964883" References: <89c0c52c0609180937n55bd7b0ch54fc38a7ebee7690@mail.gmail.com> <89c0c52c0609181119i3e60ae2bw3db4da7b70e4d6c6@mail.gmail.com> <690511EF-0349-4323-87C4-124C579DB1D8@apache.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_75191_30886231.1158614964883 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Marc, Thanks. And, I fully understand that any change would be more than just extending the parser... :-) Kevin On 9/18/06, Marc Prud'hommeaux wrote: > > Kevin- > > On Sep 18, 2006, at 11:19 AM, Kevin Sutter wrote: > > > Thanks Craig and Marc, > > I had found this reference in the spec, but it still wasn't clear > > to me. > > Maybe I'm reading it wrong, but the BNF states (in Section 4.10): > > > > update_item ::= [identification_variable.] {state_field | > > single_valued_association_field} = new_value > > > > I couldn't find the definition of the > > "single_valued_association_field". I > > was wondering if there was any implication that this might allow for > > referenced fields. But, as I continue to look at the spec, I > > suppose if > > that was to be allowed, they would have specified > > "single_valued_association_path_expression"? Is that the way you > > guys are > > reading the spec? > > Yeah, they seem to have left "single_valued_association_field" out of > the BNF, only describing it textually: > > "A single_valued_association_field is designated by the name of an > association-field in a one-to-one or many-to-one relationship. The > type of a single_valued_association_field and thus a > single_valued_association_path_expression is the abstract schema type > of the related entity." > > This is a little vague, but give the following path expression BNF: > > single_valued_association_path_expression ::= identification_variable. > {single_valued_association_field.}*single_valued_association_field > > ... I think it is reasonable to infer that > "single_valued_association_field" is meant to only be a single field, > not a series of fields (or else the "*" would not be required). > > (in any case, even if the BNF did support it, the OpenJPA back-end > doesn't efficiently handle anything but updating the top-level fields > of an entity, so it would be more than just a matter of extending/ > fixing the parser to support this) > > > > > Even the BNF for "state field" implies that this would work if > > currentOrder > > was an embedded class... > > > > state_field ::= {embedded_class_state_field.}*simple_state_field > > > > Thanks, > > Kevin > > > > On 9/18/06, Craig L Russell wrote: > >> > >> Hi, > >> > >> The JPQL BNF prohibits this operation. From 4.10: > >> > >> 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 > >> > >> The update_item must be an identification variable followed by a > >> single "." with a state field or single-valued association field, so > >> no embedded object. > >> > >> Craig > >> > >> 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 > >> > >> Craig Russell > >> Architect, Sun Java Enterprise System http://java.sun.com/products/ > >> jdo > >> 408 276-5638 mailto:Craig.Russell@sun.com > >> P.S. A good JDO? O, Gasp! > >> > >> > >> > >> > > ------=_Part_75191_30886231.1158614964883--