Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rollback Object.property
Message
De
25/04/2003 21:55:32
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Rollback Object.property
Divers
Thread ID:
00781778
Message ID:
00781778
Vues:
45
Hi,
I am having my own simple business object in my project. I have problems on the OOP design here.
I have 2 BOs, Invoice and IncvoiceDetails. In Invoice.Save(), it will do TABLEUPDATE table and call InvoiceDetails.Save() as well within transaction.
My problem is, if invoiceBO save table sucessfully, but invoicedetails NOT, the object's property are not able to be rollback. How could you design it usually?
PROCEDURE MyBase.Save()
  IF THIS.oDataObject.Save()
     WITH THIS
         .lNew = .F.           && Properties that failed to rollback if invoice details save failed.
         .lDirty = .F.
     ENDIF
     RETURN .T.
  ELSE
     RETURN .F.
  ENDIF
ENDPROC

**Subclass of MyBase
PROCEDURE InvoiceBO.Save()
  THIS.BeginTrasaction()       && BEGIN TRANSACTION

  IF NOT DODEFAULT()
    RETURN .F.
  ENDIF

  IF THIS.oInvoiceDetails.Save()
    THIS.Commit()              && END TRANSACTION
    RETURN .T.
  ELSE
    THIS.RollBack()            && ROLLBACK
    RETURN .F.
  ENDIF    
ENDPROC

**Subclass of MyBase
PROCEDURE InvoiceDetailsBO.Save()
ENDPROC
I used to think of "rollback" the properties lNew and lDirty in InvoiceBO.Save if transaction failed. It seem works since here. However, if that is more than one BO.property need to be rollback ex. CustomerBO that may be within invoiceBo, then how could I rollback property especially if that may be PROTECTED property?

Thank you
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...
Répondre
Fil
Voir

Click here to load this message in the networking platform