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 void persist(EntityOperations context) { EntityMeta entityMeta = context.getEntityMeta(); Object entity = context.getEntity(); log.debug("Persisting transient entity {}", entity); if (entityMeta.structure().isClusteredCounter()) { counterPersister.persistClusteredCounters(context); } else { context.pushInsertStatement(); counterPersister.persistCounters(context, entityMeta.getAllCounterMetas()); } }