* @param entity
*/
public void refresh(Object entity){
try {
verifyOpen();
UnitOfWork uow = getActivePersistenceContext(checkForTransaction(!isExtended()));
if(!contains(entity, uow)) {
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("cant_refresh_not_managed_object", new Object[]{entity}));
}
ReadObjectQuery query = new ReadObjectQuery();
query.setSelectionObject(entity);
query.refreshIdentityMapResult();
query.cascadeByMapping();
query.setLockMode(ObjectBuildingQuery.NO_LOCK);
Object refreshedEntity = null;
refreshedEntity = uow.executeQuery(query);
if(refreshedEntity == null) {
//bug3323, should also invalidate the shared cached object if object not exists in DB.
uow.getParent().getIdentityMapAccessor().invalidateObject(entity);
throw new EntityNotFoundException(ExceptionLocalization.buildMessage("entity_no_longer_exists_in_db", new Object[]{entity}));
}
} catch (RuntimeException e) {
this.setRollbackOnly();
throw e;