protected void lookup_depositAccount_Account(FinancialAccountAcctDs ds, FinancialAccountAcct e)
      throws Exception {
    if (ds.getDepositAccount() != null && !ds.getDepositAccount().equals("")) {
      Account x = null;
      try {
        x = ((IAccountService) findEntityService(Account.class)).findByCode(ds.getDepositAccount());
      } catch (javax.persistence.NoResultException exception) {
        throw new Exception(
            "Invalid value provided to find `Account` reference:  `depositAccount` = "
                + ds.getDepositAccount()
                + "  ");
      }
      e.setDepositAccount(x);

    } else {
      e.setDepositAccount(null);
    }
  }
  @Override
  protected void modelToEntityReferences(
      FinancialAccountAcctDs ds, FinancialAccountAcct e, boolean isInsert) throws Exception {

    if (ds.getFinancialAccountId() != null) {
      if (e.getFinancialAccount() == null
          || !e.getFinancialAccount().getId().equals(ds.getFinancialAccountId())) {
        e.setFinancialAccount(
            (FinancialAccount) this.em.find(FinancialAccount.class, ds.getFinancialAccountId()));
      }
    } else {
      this.lookup_financialAccount_FinancialAccount(ds, e);
    }

    if (ds.getAccSchemaId() != null) {
      if (e.getAccSchema() == null || !e.getAccSchema().getId().equals(ds.getAccSchemaId())) {
        e.setAccSchema((AccSchema) this.em.find(AccSchema.class, ds.getAccSchemaId()));
      }
    } else {
      this.lookup_accSchema_AccSchema(ds, e);
    }

    if (ds.getDepositAccountId() != null) {
      if (e.getDepositAccount() == null
          || !e.getDepositAccount().getId().equals(ds.getDepositAccountId())) {
        e.setDepositAccount((Account) this.em.find(Account.class, ds.getDepositAccountId()));
      }
    } else {
      this.lookup_depositAccount_Account(ds, e);
    }

    if (ds.getWithdrawalAccountId() != null) {
      if (e.getWithdrawalAccount() == null
          || !e.getWithdrawalAccount().getId().equals(ds.getWithdrawalAccountId())) {
        e.setWithdrawalAccount((Account) this.em.find(Account.class, ds.getWithdrawalAccountId()));
      }
    } else {
      this.lookup_withdrawalAccount_Account(ds, e);
    }
  }