Hi guys, May someone post sample how to correctly update eg. 1k entities ?
I tried sth like this -> [pseudo]
try(Transaction t){
getEntityManager
Query q = getEntities
Entities= q.getResultList
loop Entity from Entities{
Entity.setNewState(state)
EntityManager.merge(Entity)
.....
Query q = EntityManager.createNativeQuery(UPDATE STATEMENT)
q.executeUpdate()
}
t.commit
}
I always endup in loop with ResultSet closed or EntityManager closed errors. I guess it is caused due to long runing transaction. Creating separate transaction for each entity update is way to go ? Or commitRetaining method ?
Thank you for any comment.