This is a simple question may be
in my code i am doing a
user = em.find(User,pk);
user.setName("name");
em.flush();
after this flush() statemenet using debugger i stop using a breakpoint. I now check using my sql developer tool to see if the changes have been made in DB. I dont see the changes completed in DB.
What does this mean about flush command.
- The sql generated by the flush will be send to DB but then on the db it is queued up waiting for a commit statement to come through ? and the sql statements are not applied yet ?
Modification 1: So may be i was not clear the first time as to what i am trying to do
I have a clustered setup where on Node 1: in Transaction 1 one i am changing some parameters , say name of User entity and doing a flush() on them so thy get to DB. I cannot do a commit yet as there are lot other operations which needs to happen in transaction
Parallel to this On Node(Machine) 2 in Transaction 1 i am getting the user entity. Now in this transaction the only desire is to check the latest name on the user. This is what happens parallely and what i need to do . Can someone let me know how to do this so that distributed nodes see the latest changes.
Node 1 Node 2
try{ try {
em.getTransaction.begin em.getTransaction.begin
user = em.find(User,pk);
System.out.println.(user.getName())
/* this prints JERRY*/
user.setName("TOM");
em.flush();
...
... user = em.find(User,pk);
System.out.println.(user.getName())
/*This should print TOM*/
...
em.commit() //no commit in this transaction
} catch (Exception e) { } finally {
//rollback }
} finally {
}