Package org.activejpa

Examples of org.activejpa.ActiveJpaException


  public void updateAttributes(Map<String, Object> attributes) {
    try {
      BeanUtil.load(this, attributes);
      persist();
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while updating the attributes", e);
    }
  }
View Full Code Here


    } catch (InvocationTargetException e) {
      if (e.getCause() instanceof NoSuchMethodException) {
        logger.debug("Getter doesn't exist for the property {} in the class {}", name, bean.getClass());
        return null;
      }
      throw new ActiveJpaException("Failed while invoking the getter for the property " + name + " in the class " + bean.getClass(), e);
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while invoking the getter for the property " + name + " in the class " + bean.getClass(), e);
    }
  }
View Full Code Here

    try {
      Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass("org.apache.commons.beanutils.BeanUtils");
      Method method = clazz.getMethod("setProperty", Object.class, String.class, Object.class);
      method.invoke(null, bean, name, value);
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while setting the property", e);
    }
  }
View Full Code Here

    try {
      Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass("org.apache.commons.beanutils.PropertyUtils");
      Method method = clazz.getMethod("getPropertyDescriptor", Object.class, String.class);
      Object descriptor = method.invoke(null, bean, name);
      if (descriptor == null) {
        throw new ActiveJpaException("Property descriptor not found for the field - " + name);
      }
      method = clazz.getMethod("getReadMethod", PropertyDescriptor.class);
      return (Method) method.invoke(null, descriptor);
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while getting the property descriptor", e);
    }
  }
View Full Code Here

    try {
      Class<?> utils = Thread.currentThread().getContextClassLoader().loadClass("org.apache.commons.lang3.ClassUtils");
      Method method = utils.getMethod("isPrimitiveOrWrapper", Class.class);
      return (Boolean) method.invoke(null, clazz);
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while getting the property descriptor", e);
    }
  }
View Full Code Here

    try {
      Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass("org.apache.commons.beanutils.ConvertUtils");
      Method method = clazz.getMethod("convert", Object.class, Class.class);
      return method.invoke(null, value, targetType);
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while converting the type", e);
    }
  }
View Full Code Here

      method.invoke(parent, item);
      return item;
    } catch (NoSuchMethodException e) {
      logger.debug("Method {} doesn't exist in the class {}", methodName, parent.getClass());
    } catch (Exception e) {
      throw new ActiveJpaException("Failed while invoking the method " + method.getName(), e);
    }
   
    // Try adding the item to the collection property returned by the getter
    logger.trace("Attempting to invoke the getter for the property {} on the parent {}", name, parent);
    Collection<T> collection = (Collection<T>) PropertyUtil.getProperty(parent, name);
    if (collection != null) {
      if (add) {
        collection.add(item);
      } else {
        collection.remove(item);
      }
      return item;
    }
   
    // Try to find out the field and add/remove it to/from that
    try {
      logger.trace("Attempting to invoke the the property {} on the parent {}", name, parent);
      Field field = parent.getClass().getDeclaredField(name);
      field.setAccessible(true);
      collection = (Collection<T>) field.get(parent);
      if (add) {
        collection.add(item);
      } else {
        collection.remove(item);
      }
      return item;
    } catch (Exception e) {
      logger.error("Failed to {} the item {} to the collection of the parent", add ? "add" : "remove", item, parent);
      throw new ActiveJpaException("Failed while adding/removing the item to the collection - " + name, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.activejpa.ActiveJpaException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.