Hi,
I have a simple problem. Method refresh() on hibernate Session doesn't work. At all. What am I doing wrong? :( Here is the code:
Code:
Actor actor = (Actor) session.load(Actor.class, (short)1);
System.out.println("actor: "+actor.getFirstName()+ " " +actor.getLastName());
//Here I update the actor's name in other program - some database client
try {
Thread.sleep(10000);
}catch(Exception e){
e.printStackTrace();
}
session.refresh(actor);
System.out.println("actor: "+actor.getFirstName()+ " " +actor.getLastName());
In the end on the output I get:
Hibernate: select actor0_.actor_id as actor1_6_0_, actor0_.first_name as first2_6_0_, actor0_.last_name as last3_6_0_, actor0_.last_update as last4_6_0_ from sakila.actor actor0_ where actor0_.actor_id=?
actor: John Smith
Hibernate: select actor0_.actor_id as actor1_6_0_, actor0_.first_name as first2_6_0_, actor0_.last_name as last3_6_0_, actor0_.last_update as last4_6_0_ from sakila.actor actor0_ where actor0_.actor_id=?
actor: John Smith
As you can see it runs another select after I update the data in the database, but somehow it can not see the changes...
Help!
Kind regards,
Kania