Hey,
I was wondering regarding the behaviour of em.flush();
I have such a method:
public void testMethod() {
Collection<SomeEntity> entities = em.createNamedQuery(...).getResultList();
for (SomeEntity currEntity : entities) {
currEntity.setSomeBooleanFlag(true);
mergeEntity(currEntity);
}
em.flush();
for(SomeEntity currEntity : entities) {
//Perform some stuff here...
}
}
public void mergeEntity(SomeEntity entity) {
em.merge(entity);
}
I expected that after calling em.flush() I will see the boolean flag set for all requests iterated in the first for loop, but it doesnt.
Only after the whole method ends, I see the changes flushed in the DB,
Why? shouldn't em.flush() update the database just after it got invoked?
Thanks in advanced,
Asaf.
[Message sent by forum member 'trouby' (trouby)]
http://forums.java.net/jive/thread.jspa?messageID=216665