code: @Override
  	public T refresh(T entity) {
  
  		// Attempting to refresh a non-persisted entity
  		// will result in an exception
  		if (extractId(entity) == null) {
  			// causes exception
  			getEntityManager().refresh(entity);
  		}
  		// Case of attached empty - this gets refreshed
  		else if (getEntityManager().contains(entity)) {
  			getEntityManager().refresh(entity);
  		}
  		// Case of unattached entity, first it is necessary to perform
  		// a merge, before doing the refresh
  		else {
  			entity = getEntityManager().merge(entity);
  			getEntityManager().refresh(entity);
  		}
  
  		return entity;
  	}
docs: {@inheritDoc}