public <T> T load(PersistenceContext context, Class<T> entityClass) { log.debug("Loading entity of class {} using PersistenceContext {}", entityClass, context); EntityMeta entityMeta = context.getEntityMeta(); Object primaryKey = context.getPrimaryKey(); Validator.validateNotNull(entityClass, "Entity class should not be null"); Validator.validateNotNull( primaryKey, "Entity '%s' key should not be null", entityClass.getCanonicalName()); Validator.validateNotNull( entityMeta, "Entity meta for '%s' should not be null", entityClass.getCanonicalName()); T entity = null; if (entityMeta.isClusteredCounter()) { entity = counterLoader.loadClusteredCounters(context); } else { Row row = context.loadEntity(); if (row != null) { entity = entityMeta.instanciate(); mapper.setNonCounterPropertiesToEntity(row, entityMeta, entity); } } return entity; }