jsr338-experts@jpa-spec.java.net

[jsr338-experts] JPQL update statements and embeddables

From: Linda DeMichiel <linda.demichiel_at_oracle.com>
Date: Fri, 11 Mar 2011 17:40:09 -0800

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_field.}*{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