@Override
  public void deleteChargePoint(int chargeBoxPk) {
    ctx.transaction(
        configuration -> {
          DSLContext ctx = DSL.using(configuration);
          try {
            addressRepository.delete(ctx, selectAddressId(chargeBoxPk));
            deleteChargePointInternal(ctx, chargeBoxPk);

          } catch (DataAccessException e) {
            throw new SteveException("Failed to delete the charge point", e);
          }
        });
  }
  @Override
  public int addChargePoint(ChargePointForm form) {
    return ctx.transactionResult(
        configuration -> {
          DSLContext ctx = DSL.using(configuration);
          try {
            Integer addressId = addressRepository.updateOrInsert(ctx, form.getAddress());
            return addChargePointInternal(ctx, form, addressId);

          } catch (DataAccessException e) {
            throw new SteveException(
                "Failed to add the charge point with chargeBoxId '%s'", form.getChargeBoxId(), e);
          }
        });
  }
  @Override
  public ChargePoint.Details getDetails(int chargeBoxPk) {
    ChargeBoxRecord cbr =
        ctx.selectFrom(CHARGE_BOX).where(CHARGE_BOX.CHARGE_BOX_PK.equal(chargeBoxPk)).fetchOne();

    if (cbr == null) {
      throw new SteveException("Charge point not found");
    }

    cbr.detach();

    AddressRecord ar = addressRepository.get(ctx, cbr.getAddressPk());

    return new ChargePoint.Details(cbr, ar);
  }