public static void populateFromCache(Object entity) {
populateFromCache(entity, null);
}
public static void populateFromCache(Object entity, String propertyName) {
HydratedCacheManager manager = HydratedCacheEventListenerFactory.getConfiguredManager();
HydrationDescriptor descriptor = ((HydratedAnnotationManager) manager).getHydrationDescriptor(entity);
if (!MapUtils.isEmpty(descriptor.getHydratedMutators())) {
Method[] idMutators = descriptor.getIdMutators();
String cacheRegion = descriptor.getCacheRegion();
for (String field : descriptor.getHydratedMutators().keySet()) {
if (StringUtils.isEmpty(propertyName) || field.equals(propertyName)) {
try {
Serializable entityId = (Serializable) idMutators[0].invoke(entity);
Object hydratedItem = manager.getHydratedCacheElementItem(cacheRegion, getInheritanceHierarchyRoot(entity.getClass()), entityId, field);
if (hydratedItem == null) {
Method factoryMethod = entity.getClass().getMethod(descriptor.getHydratedMutators().get(field).getFactoryMethod(), new Class[]{});
Object fieldVal = factoryMethod.invoke(entity);
manager.addHydratedCacheElementItem(cacheRegion, getInheritanceHierarchyRoot(entity.getClass()), entityId, field, fieldVal);
hydratedItem = fieldVal;
}
descriptor.getHydratedMutators().get(field).getMutators()[1].invoke(entity, hydratedItem);
} catch (InvocationTargetException e) {
if (e.getTargetException() != null && e.getTargetException() instanceof CacheFactoryException) {