jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: JPQL update statements and embeddables

From: Evan Ireland <eireland_at_sybase.com>
Date: Mon, 14 Mar 2011 09:52:17 +1300

Since:

    e.address.building = 14

would be false, you would not expect the "SET" clause to be relevant.

I presume you are just saying that:

    SET a.b.c = x

will result in a.b being non-null if it was previously null.

> -----Original Message-----
> From: Linda DeMichiel [mailto:linda.demichiel_at_oracle.com]
> Sent: Monday, 14 March 2011 9:48 a.m.
> To: Werner Keil
> Cc: jsr338-experts_at_jpa-spec.java.net
> Subject: [jsr338-experts] Re: JPQL update statements and embeddables
>
> Hi Werner,
>
> I think the new values should be set.
>
> -Linda
>
>
> On 3/13/2011 12:17 PM, Werner Keil wrote:
> > Looks good to me.
> >
> > What happens, if e.address was null? Are these values
> ignored or is an
> > exception thrown?
> >
> > Werner
> >
> > ----- Original Message ----- From: "Linda DeMichiel"
> > <linda.demichiel_at_oracle.com>
> > To: <jsr338-experts_at_jpa-spec.java.net>
> > Sent: Saturday, March 12, 2011 7:10 AM
> > Subject: [jsr338-experts] JPQL update statements and embeddables
> >
> >
> >> The syntax for the JPQL bulk update statement is:
> >>
> >> update_statement ::= update_clause [where_clause]
> >> update_clause ::= UPDATE entity_name [[AS] identification_variable]
> >> SET update_item {, update_item}*
> >> update_item ::= [identification_variable.]{state_field |
> >> single_valued_object_field} =
> >> new_value
> >> new_value ::=
> >> scalar_expression |
> >> simple_entity_expression |
> >> NULL
> >>
> >>
> >> This seems too restrictive, in that it does not allow for
> the updating
> >> of embeddables that are directly contained in entities
> (i.e., stored
> >> in the entity table).
> >>
> >> I propose the following update to the syntax and semantics
> to allow the
> >> update of state fields or single-valued association fields that are
> >> contained as the "leaf-node" state of embeddables.
> >>
> >> update_item ::=
> >>
> [identification_variable.]{single_valued_embeddable_object_fie
> ld.}*{state_field
> >> | single_valued_object_field} = new_value
> >>
> >>
> >> Example UPDATE statement (and real world example :-) )
> >>
> >> UPDATE Employee e
> >> SET e.address.building = 22
> >> WHERE e.address.building = 14
> >> AND e.address.city = 'Santa Clara'
> >> AND e.project = 'Java EE'
> >>
> >>
> >> Opinions ??
> >>
> >> thanks,
> >>
> >> -Linda
> >
>