Let's say I create JPA requests in a loop:
for(A elem : collection) {
emanager.createQuery("update A a set a.x=:y where a.id=:id")
.setParameter("id",elem.id)
.setParameter(":y", 123)
.executeUpdate();
}
Is it possible to reuse the returned instance Query?
Query query = emanager.createQuery("update A a set a.x=:y where a.id=:id");
for(A elem : collection) {
query
.setParameter("id",elem.id)
.setParameter(":y", 123)
.executeUpdate();
}
Does it apply to all instances Query? NamedQuery, NativeQueryetc. Of course, I'm talking about reusing an instance in the same EntityManager, i.e. As part of the same transaction
source
share