Re: Database transactions and data-state flags



Can you elaborate on now MTS would handle this? would the need for flags be
removed? would each object need to handle its own persistence?

Thanks.

"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:IKKdnT9-gMvvUtXYnZ2dnUVZ_qudnZ2d@xxxxxxxxxxxxxxx

"Craig Buchanan" <someone@xxxxxxxxxxxxx> wrote in message
news:e4G%23U6c$GHA.204@xxxxxxxxxxxxxxxxxxxxxxx
I am attempting to create an API layer for my application. The UI
interacts
with the API, the API interacts with the database.

Essentially, each object is responsible for its persistence. At this
point,
I use flags (IsNew or IsDirty) to indicate the state data of the object's
data. When the data has been saved successfully to the database, the
flags
are switched off. This works fine for a simple object.

If, however, I have an object that has collections, the state management
becomes more complex. Consider an Invoice object that has a LineItems
collection of LineItem objects. I want to create a database transaction
to
ensure that the hierarchy is save successfully as a whole. It seems that
I
need to follow this logic:
* create a transaction
* save the Invoice, if necessary
* iterate the LineItems collection, save the LineItem, if necessary
* commit the transaction
* reset the Invoice's flags
* iterated the LineItems collection, reset each LineItem's flags

I don't want to reset the LineItem's flags during the database update
process; if the transaction fails, the flags' settings wouldn't match the
data's true state.

Does this seem reasonable? Is there an alternate approach to this that
avoids flags?

Thanks for your thoughts.

Craig Buchanan


Why not use MTS (COM+). That's what it was designed for.

But like Mr. Hyde said - there ain't wrong with flags.

-ralph




.



Relevant Pages

  • Database transactions and data-state flags
    ... I am attempting to create an API layer for my application. ... I use flags to indicate the state data of the object's ... When the data has been saved successfully to the database, ... Consider an Invoice object that has a LineItems ...
    (microsoft.public.vb.general.discussion)
  • Re: Database transactions and data-state flags
    ... When the data has been saved successfully to the database, the flags ... Consider an Invoice object that has a LineItems ... I want to create a database transaction ...
    (microsoft.public.vb.general.discussion)
  • Re: Database transactions and data-state flags
    ... I use flags to indicate the state data of the object's ... When the data has been saved successfully to the database, ... Consider an Invoice object that has a LineItems ... I want to create a database transaction to ...
    (microsoft.public.vb.general.discussion)
  • Re: Database transactions and data-state flags
    ... My question was related to how to make my objects "MTS aware". ... I execute database calls in each class' Save method. ... I create a transaction to do this. ... but it seems like i'll still need to deal w/ flags. ...
    (microsoft.public.vb.general.discussion)
  • Re: ATA_FLUSHCACHE failing
    ... I'll set the IMMEDIATE_MODE flags where it hangs and report back. ... transaction ... ...
    (freebsd-current)