There is Java entity class:
class Call {
int callId,
String callStatus
}
callStatus posibly values : SETUP, INSTALLED, FINISHED
And table calls_statuses has values
callId callStatus
1 SETUP
2 INSTALLED
3 INSTALLED
Then i need change statuses for callId 1 and 2 as :
1 INSTALLED
2 FINISHED
The call with callId 3 left same.
Is it possible to make a batch update using Spring JPA/Hibernate?
Try something like this, a custom JPQL query would like:
@Query("Update CallStatuses cs SET cs.callStatus = CASE WHEN (cs.callId IN :calls1) THEN :callStatusInstalled WHEN (cs.id IN :calls2) THEN :callStatusFinished END")
batchUpdateCallStatus(@Param("calls1")List<int> calls1,
@Param("calls2") List<int> calls2,
@Param("callStatusInstalled") String callStatusInstalled,
@Param("callStatusFinished") String callStatusFinished);
Posssible duplicate: JPQL - Update with Multiple where conditions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.