[DEV] simple rework the Check JPA

This commit is contained in:
Edouard DUPIN 2024-05-28 18:04:31 +02:00
parent 0e498c6a26
commit 38d1fa9241

View File

@ -121,13 +121,10 @@ public class CheckJPA<T> implements CheckFunctionInterface {
return; return;
} }
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class); final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
long count = 0; final Condition conditionCheck = condCheckers.isEmpty() ? null
if (condCheckers.isEmpty()) { : condCheckers.get(0).toCondition();
count = DataAccess.count(annotationManyToOne.targetEntity(), elem); final long count = DataAccess.count(annotationManyToOne.targetEntity(), elem,
} else { conditionCheck);
count = DataAccess.count(annotationManyToOne.targetEntity(), elem,
condCheckers.get(0).toCondition());
}
if (count == 0) { if (count == 0) {
throw new InputException(baseName + fieldName, throw new InputException(baseName + fieldName,
"Foreign element does not exist in the DB:" + elem); "Foreign element does not exist in the DB:" + elem);