[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;
}
final List<ConditionChecker> condCheckers = options.get(ConditionChecker.class);
long count = 0;
if (condCheckers.isEmpty()) {
count = DataAccess.count(annotationManyToOne.targetEntity(), elem);
} else {
count = DataAccess.count(annotationManyToOne.targetEntity(), elem,
condCheckers.get(0).toCondition());
}
final Condition conditionCheck = condCheckers.isEmpty() ? null
: condCheckers.get(0).toCondition();
final long count = DataAccess.count(annotationManyToOne.targetEntity(), elem,
conditionCheck);
if (count == 0) {
throw new InputException(baseName + fieldName,
"Foreign element does not exist in the DB:" + elem);