public void refresh(Object proxifiedEntity, EntityOperations context) throws AchillesStaleObjectStateException { Object primaryKey = context.getPrimaryKey(); log.debug( "Refreshing entity of class {} and primary key {}", context.getEntityClass().getCanonicalName(), primaryKey); ProxyInterceptor<Object> interceptor = proxifier.getInterceptor(proxifiedEntity); Object entity = context.getEntity(); interceptor.getDirtyMap().clear(); Object freshEntity = loader.load(context, context.getEntityClass()); if (freshEntity == null) { throw new AchillesStaleObjectStateException( "The entity '" + entity + "' with primary_key '" + primaryKey + "' no longer exists in Cassandra"); } interceptor.setTarget(freshEntity); interceptor.getAlreadyLoaded().clear(); interceptor.getAlreadyLoaded().addAll(context.getAllGettersExceptCounters()); }
public <T> T buildProxyWithAllFieldsLoadedExceptCounters(T entity, EntityOperations context) { return buildProxy(entity, context, context.getAllGettersExceptCounters()); }