Multiple Queries during insert

I’m doing a simple insert operation. Before I do the insert, I check if the value already exists. This is where I’m having issues. I can see the SELECT query is getting executed 4 times instead of one.
This is how I check for the existence of value

        boolean unitNameAlreadyExists = unitService.isUnitNameAlreadyExists(value);"unitName {} AlreadyExists ? {}", value,unitNameAlreadyExists);
        return !unitNameAlreadyExists;

and the JPA method is ```@Query("select (count(u) > 0) from Unit u where upper(u.unitName) = upper(:unitName)")
    boolean existsByUnitNameIgnoreCase(@Param("unitName") String unitName);```

The binder is ``` private Binder.Binding<Unit, String> addUnitNameValidator() {"Binding additional validations for unit name {}", unitName.getValue());
        Binder.Binding<Unit, String> unitNameValidator = binder.forField(unitName)
                .withValidator(s -> checkUnitNameAlreadyExists(s), "Unit name already exists")
        return unitNameValidator;

```  public void addAdditionalValidators() {
        if (binder.isValid()) {
  "Adding validator for unit name");
            Binder.Binding<Unit, String> unitNameValidator = addUnitNameValidator();
            if (!binder.validate().getBeanValidationErrors().isEmpty()) {
    }```.  What am  I doing wrong here and how to prevent the query running mulitple times ?

Don’t use a binder if you are worried for the amount of calls of the validation, that runs pretty often.

You can isUnitNameAlreadyExists when the field is updated by the user (e.isFromClient on addValueChangeListener) to give an immediate feedback and check it when the save is called.
That should be 2 queries in total when the unit name is updated.
And the code would be less complicated.
In your case your are validating the binder with binder.isValid() then revalidate the binder with binder.validate().