AssociationType at = ModelUtilities.getAssociationType(f, mode);
if (f.getAnnotation(PersistentAttribute.class) != null){
try {
if (fieldValue == null && AssociationType.REQUIRED.equals(at)) {
throw new InternalErrorException("PersistAction::persistAssociatedAttributes -> You tried to persist a null value for " +
"a required associated attribute: " + f.getName());
} else if (fieldValue == null) {
continue;
} else if (fieldValue != null && !AssociationType.NONE.equals(at)) {
f.set(entity, new PersistAction(fieldValue, mode).execute(connection));
}
} catch (DuplicateInstanceException e) {
if (AssociationType.REQUIRED.equals(at)) {
logger.log(Level.WARNING, "PersistAction::execute::persistAssociatedAttributes -> You tried to persist (" + mode + ") an " +
"associated entity that it's already in the database: " + f.get(entity).toString());
throw e;
}
} catch (DataNotFoundException e) {
if (AssociationType.REQUIRED.equals(at)) {
logger.log(Level.WARNING, "PersistAction::execute::persistAssociatedAttributes -> You tried to persist (" + mode + ") an " +
"associated entity that it's not in the database: " + f.get(entity).toString());
throw e;
}
}
} else if (f.getAnnotation(AssociatedEntityList.class) != null) {
if (fieldValue == null && AssociationType.REQUIRED.equals(at)) {
throw new InternalErrorException("PersistAction::persistAssociatedAttributes -> You tried to persist a null value for " +
"a required associated entity list: " + f.getName());
} else if (fieldValue == null) {
continue;
}
ArrayList<?> associatedEntityList = (ArrayList<?>) fieldValue;