ObjectDB ObjectDB

selective update does not work

#1

we try to update a single attribute of a number of objects using:

update Action set transferred = 1 where objectsInCharge.nodePath = '/(MA)ENTRYLEVEL-1'

it returns:

 

Query Execution Error
=====================
null

 

in the docs it is written to use something like:

UPDATE Country
SET population = population * 11 / 10
WHERE c.population < :p

trying to use then

update Action set transferred = 1 where a.objectsInCharge.nodePath = '/(MA)ENTRYLEVEL-1'

ends up with 

Query Execution Error
=====================
Unexpected query token 'a'
update Action set transferred = 1 where  ==> a <== .objectsInCharge.nodePath = '/(MA)ENTRYLEVEL-1'
 

the normal query has for sure a number of results

select a from Action a where a.objectsInCharge.nodePath = '/(MA)ENTRYLEVEL-1'

 

 

 

 

 

 

 

 

 

edit
delete
#2

JPA UPDATE queries are limited to one variable and your query uses an implicit JOIN, i.e. it is a shortcut for a query with 2 variables (or 2 entities / tables). See also post #4 in this thread.

Regarding the documentation, there is indeed an error. It should be:

UPDATE Country SET population = population * 11 / 10 WHERE population < :p

rather than 

UPDATE Country SET population = population * 11 / 10 WHERE c.population < :p

Thank you for this report. We will fix it.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.