openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: Does OpenJPA support updating of related objects via JPQL?
Date Mon, 18 Sep 2006 18:19:21 GMT
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?

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 <Craig.Russell@sun.com> 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
> > .<init>(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!
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message