I'm curious:
What would the internals of PersonManager.beginTransaction(),
PersonManager.commitTransaction(), and PersonManager.rollbackTransaction() look like?
I am especially interested in the case where the PersonObject has 1 or more nested
objects. For example, what if the PersonObj had an AddressObject and you wanted to
submit the PersonObj and AddressObj changes in one "transaction"?
I assume getPersonPersister().persistPerson(person) or the PersonManager would then
call some sort of AddressManager who would call a
getAddressPersister.persistAddress(address).
But would this work with a transaction that would support a full rollback of address
and person changes in the case of a problem?
Would you use a Memento Object for the Person and for the Address prior to storing the
new object state and then the rollbackTransaction, if called, would reinstate the
Memento Objects?
Thanks,
Jon
>>> [EMAIL PROTECTED] 10/16/03 01:56PM >>>
I'd opt for a single PersonPersistor instance (stored in the PersonManager)
that takes a Person object and persists it. The Person object itself has no
knowledge of persistance. So my Listener would call
PersonManger.persistPerson(personObj) which would, in turn, defter that to
the PersonPersister.persist(personObj) method to do the actual work.
PersonListener:
method submitPerson(person)
PersonManager.beginTransaction();
try {
PersonManager.persistPerson(person)
PersonManager.commitTransaction();
} catch (any e) {
PersonManager.rollbackTransaction();
}
}
PersonManager:
method persistPerson(person) {
getPersonPersister().persistPerson(person);
}
PersonPersister:
method persistPerson(person) {
CFQUERY
UPDATE person SET ...
}
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Justin Balog
> Sent: Thursday, October 16, 2003 12:40 PM
> To: '[EMAIL PROTECTED]'
> Subject: [CFCDev] Strugling With Persistence
>
>
>
> I understand the reason to abstract the mechanism of persistence from the
> application. I think I have a reasonable grasp on that, however, I am not
> quite sure how to do it. As always, back to my person example. I don't
> think the person.obj should be able to save itself (Terminiator Theory).
> What I have is a PersonPersistor.obj. As for instance data, the
> PersonPersistor.obj has a coouple instance vars including some
> env. infa and
> objectToPersist, which simply stores the personDTO(). Then, anytime I want
> to save something, I create the PersonPersistor and initialize it with the
> personDTO.obj and execute the persistor.persist().
>
> Rough Pseudo Code:
> <event filter person beaner>
> PersonBeaner construct person object
> </event filter>
> <PersonLIstener>
> method submitPerson()
> modelCFC.beginTransaction();
> try {
> personPersistor = CreateObjcet('comp',PersonPersistor);
> Persistor.init(some env. vars like DSN, and
> person.getDTO());
> Persistor.persist();
> modelCFC.commitTransaction();
> } catch (any e) {
> modelCFC.rollbackTransaction();
> }
>
> </PersonListener>
>
> What do you think? Thanks much in advance.
>
> Justin
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]