-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: session.refresh() doesn't work
PostPosted: Fri Feb 08, 2013 11:37 am 
Newbie

Joined: Thu Feb 07, 2013 8:12 am
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: session.refresh() doesn't work
PostPosted: Fri Feb 08, 2013 12:06 pm 
Newbie

Joined: Thu Feb 07, 2013 8:12 am
Posts: 3
Ok. My mistake... Already changed the transaction isolation level from 1 to 2. It works now..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.