/** @see de.willuhn.datasource.db.AbstractDBObject#delete() */
  public void delete() throws RemoteException, ApplicationException {
    try {
      this.transactionBegin();

      super.delete();

      // und noch in's Protokoll schreiben.
      Konto k = this.getKonto();
      if (k != null)
        k.addToProtokoll(
            i18n.tr(
                "Auftrag [Gegenkonto: {0}, Kto. {1}, BLZ {2}] {3} {4} gelöscht",
                getGegenkontoName(),
                getGegenkontoNummer(),
                getGegenkontoBLZ(),
                k.getWaehrung(),
                HBCI.DECIMALFORMAT.format(getBetrag())),
            Protokoll.TYP_SUCCESS);

      this.transactionCommit();
    } catch (RemoteException re) {
      this.transactionRollback();
      throw re;
    } catch (ApplicationException ae) {
      this.transactionRollback();
      throw ae;
    }
  }
  /**
   * @see de.willuhn.datasource.db.AbstractDBObject#overwrite(de.willuhn.datasource.rmi.DBObject)
   */
  public void overwrite(DBObject object) throws RemoteException {
    // Muessen wir ueberschreiben, weil wir fuer das Konto hier eine
    // Sonderbehandlung machen. Wuerden wir das hier nicht machen,
    // haetten wir nach dem Overwrite ploetzlich ein Konto-Objekt
    // statt der Konto-ID in den Properties. Das liegt eigentlich
    // nur daran, weil wir "konto_id" hier nicht als Foreign-Key
    // (wegen dem Cache) deklariert haben - bei "getAttribute("konto_id")"
    // aber trotzdem das Objekt (wegen KontoColumn) zurueckliefern.
    super.overwrite(object);

    // Jetzt ersetzen wir wieder das Konto-Objekt gegen die ID
    this.setKonto(((AbstractHibiscusTransferImpl) object).getKonto());
  }
  /** @see de.willuhn.datasource.db.AbstractDBObject#store() */
  public void store() throws RemoteException, ApplicationException {
    try {
      this.transactionBegin();
      super.store();

      Konto k = this.getKonto();
      String blz = getGegenkontoBLZ();
      if (blz != null) {
        String[] params =
            new String[] {
              getGegenkontoName(),
              getGegenkontoNummer(),
              getGegenkontoBLZ(),
              k.getWaehrung(),
              HBCI.DECIMALFORMAT.format(getBetrag())
            };
        k.addToProtokoll(
            i18n.tr("Auftrag [Gegenkonto: {0}, Kto. {1}, BLZ {2}] {3} {4} gespeichert", params),
            Protokoll.TYP_SUCCESS);
      } else {
        String[] params =
            new String[] {
              getGegenkontoName(),
              getGegenkontoNummer(),
              k.getWaehrung(),
              HBCI.DECIMALFORMAT.format(getBetrag())
            };
        k.addToProtokoll(
            i18n.tr("Auftrag [Gegenkonto: {0}, Kto. {1}] {2} {3} gespeichert", params),
            Protokoll.TYP_SUCCESS);
      }

      this.transactionCommit();
    } catch (RemoteException re) {
      try {
        this.transactionRollback();
      } catch (Exception e2) {
        Logger.error("unable to rollback transaction", e2);
      }
      throw re;
    } catch (ApplicationException ae) {
      try {
        this.transactionRollback();
      } catch (Exception e2) {
        Logger.error("unable to rollback transaction", e2);
      }
      throw ae;
    }
  }