简体   繁体   中英

JPA 2.0 JPQL Update

I am facing a different behaviour of hibernate update, I am running a simple JPQL to update the workpool of my tasks and its firing select-insert and bulk-update queries to update my task's workpool.

Below is my method to move my task to workpool:

public Boolean changeWorkpool(final TaskWorkpoolChangeRequest taskWorkpoolChangeRequest) {
final Query query = entityManager.createQuery("UPDATE Task SET workpoolId = :workpoolId"
    + " WHERE taskId= :taskId");
query.setParameter("workpoolId", taskWorkpoolChangeRequest.getWorkpoolId())
    .setParameter("taskId", taskWorkpoolChangeRequest.getTaskId());
return BooleanUtils.toBoolean(query.executeUpdate());

}

Here are the queries executing on the server:

Hibernate: /* select insert */ insert into HT_task select task0_.task_id as task_id 
from task task0_ left outer join task_manager manager0_1_ on task0_.task_id=manager0_1_.task_id 
left outer join task_employee employee0_2_ on task0_.task_id=employee0_2_.task_id 
where task0_.task_id=?

Hibernate: /* bulk update */ update task set workpool_id=? where (task_id) 
IN (select task_id from HT_task)

Is it the expected behaviour of hibernate to execute update queries or am i missing anything?

Can anyone please give some pointers on this.

Thanks

我在这里对Java中的批量操作有一个不错的解释: http : //in.relation.to/2072.lace

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM