JPQL - refresh with Multiple where conditions
An instance of the case is supported in JPA 2.0. I have provided pseudocode, I can make the appropriate changes.
-
You can try to execute your JPQL query with
CASE
.Update Person p set p.name = CASE WHEN (p.id = :id1) THEN :name_1 WHEN (p.id = :id2) THEN :name_2 WHEN (p.id = :id3) THEN :name_3 END
general_case_expression :: = CASE WHEN conditional_expression THEN scalar_expression ELSE scalar_expression END
-
Otherwise, try the criteria API to create a request.
when (expression condition, R result): add when / then expression points to case expression.
criteriaBuilder.selectCase().when(criteriaBuilder.equal(person.get("id"), id1), name_1);
source to share