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