private static Getter getGetter(Property mappingProperty) {
    if (mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation()) {
      return null;
    }

    PropertyAccessor pa =
        PropertyAccessorFactory.getPropertyAccessor(mappingProperty, EntityMode.POJO);
    return pa.getGetter(
        mappingProperty.getPersistentClass().getMappedClass(), mappingProperty.getName());
  }
Example #2
0
 @SuppressWarnings("unchecked")
 private void addSubElement(Property property, ValidatableElement element) {
   if (property != null && property.isComposite() && !property.isBackRef()) {
     Component component = (Component) property.getValue();
     if (component.isEmbedded()) return;
     PropertyAccessor accessor =
         PropertyAccessorFactory.getPropertyAccessor(property, EntityMode.POJO);
     Getter getter = accessor.getGetter(element.clazz, property.getName());
     ClassValidator validator = new ClassValidator(getter.getReturnType());
     ValidatableElement subElement =
         new ValidatableElement(getter.getReturnType(), validator, getter);
     Iterator properties = component.getPropertyIterator();
     while (properties.hasNext()) {
       addSubElement((Property) properties.next(), subElement);
     }
     if (subElement.getSubElements().size() != 0 || subElement.validator.hasValidationRules()) {
       element.addSubElement(subElement);
     }
   }
 }