-->
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: Hibernate 4.1.8 object won't refresh from database
PostPosted: Wed Dec 05, 2012 10:51 am 
Newbie

Joined: Wed Dec 05, 2012 10:38 am
Posts: 2
Hi,

I have an issue where an object that was updated outside of Hibernate (using MySQL Workbench) is not getting refreshed. What happens is that I do a call to the Hibernate application and check the value, then do an update to a value of the object using Workbench, save and check that the value is set and do another call in Hibernate after refreshing and still the old value is there. The object does gets resfreshed on the third call but I need this to happen straight away -- I cannot afford to use old data in this instance.

Code:
Query q = session.createQuery("SELECT object(o) FROM PortedNumber o WHERE o.number = '" + agiRequest.getDnid() + "'");
List<PortedNumber> portedNumberList = q.list();
if (!portedNumberList.isEmpty()) {
   for (PortedNumber portedNumber : portedNumberList) {
      session.evict(portedNumber);
      session.refresh(portedNumber, LockOptions.READ);
      PortedNumber num = (PortedNumber) session.get(PortedNumber.class, portedNumber.getId());   
      session.refresh(num);
      networkId = num.getNetwork().getId();
      logger.info("Number is ported to networkId = " + networkId);
      break;
   }
}


Any pointers/help would be most weclome.

Regards


Top
 Profile  
 
 Post subject: Re: Hibernate 4.1.8 object won't refresh from database
PostPosted: Thu Dec 06, 2012 7:29 am 
Newbie

Joined: Wed Dec 05, 2012 10:38 am
Posts: 2
Solved on Stackoverflow: http://stackoverflow.com/questions/13739446/hibernate-object-refresh-not-happening


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.