Refresh value on connection

using Hibernate, I would like to update the data in the database based on conditions, but I got the following error: "node to move cannot be null"

Here is my database description:

Account: id, email, password
Member : id, account, team
Team: id, current (and a reference to member => members)

Here is my JPA:

UPDATE Team t SET t.current = :current LEFT JOIN t.members m WHERE t.current = :current_true AND m.account = :account

What am I doing wrong? If I move the LEFT JOIN to SET:

UPDATE Team t LEFT JOIN t.members m SET t.current = :current WHERE t.current = :current_true AND m.account = :account

I got: "waiting for SET, found LEFT"

If I remove the connection:

UPDATE Team t SET t.current = :current WHERE t.current = :current_true AND t.members.account = :account

I got: "An illegal attempt to dereference a collection."

What is the correct way to update values?

Thank you for your help!

+5
source share
2 answers

JPA 2.0 4 JPQL. "update":

:

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

, . , , , , , , , . SQL.

+7

:

( )

UPDATE Team t SET t.current = :current 
WHERE t.id in (select t1.id from Team t1  LEFT JOIN t1.members m WHERE t1.current = :current_true AND m.account = :account)
+11

All Articles