I got a decent explanation of the bulk operations in java here: http://in.relation.to/2072.lace
JPA 2.0 JPQL Update
Pregunta
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
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow