[transfer-dev] Re: Trying not to think in terms of tables

2009-11-02 Thread Tom McNeer
You're headed in the right direction, looking to use the composed
relationships. But ...

On Mon, Nov 2, 2009 at 2:19 PM, jqdur...@gmail.com wrote:

 My first exercise in saving an Address, did so without regard of the
 CompanyID. Essentially, the handler took the AddressID, located the correct
 Transfer Object, cloned it, populated, validated and saved the Address
 without any knowledge of a Company. This seemed to be working fine.


... if you are working with a database record that currently exists and has
the Company relationship attached, you don't need to deal with the Company
at all. The Address object knows what its parent Company is, and if you
don't need to change it, then you don't have to mess with it at all.

For a new record, you'd need to use the CompanyID to retrieve the Company
object, then do Address.setParentCompany(myCompany), or something like that,
before saving the Address record.

But if the Address already has a Company, most times you can just ignore it.
(Unless of course, you actually need the Company for another reason.)

But why did you need to clone the object?


Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
transfer-dev group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~--~~~~--~~--~--~---



[transfer-dev] Re: Trying not to think in terms of tables

2009-11-02 Thread Jason Durham
Ah... I hadn't considered that the Address was already aware of its parent.
Dealing with the Address object directly was less painful. :)

With regard to cloning...  isn't that the only way to do it? :o)   My
validation mechanism occurs once the Transfer Object has been populated.  I
don't want the (potentially) invalid form data to dirty the cache until it
has been validated.  If the object doesn't validate, I pass the entire
object back to the form to output errors.

Jason


On Mon, Nov 2, 2009 at 2:06 PM, Jason Durham ja...@durhamcons.com wrote:

 Ah... I hadn't considered that the Address was already aware of its
 parent.  Dealing with the Address object directly was less painful. :)

 With regard to cloning...  isn't that the only way to do it? :o)   My
 validation mechanism occurs once the Transfer Object has been populated.  I
 don't want the (potentially) invalid form data to dirty the cache until it
 has been validated.  If the object doesn't validate, I pass the entire
 object back to the form to output errors.

 Jason




 On Mon, Nov 2, 2009 at 1:46 PM, Tom McNeer tmcn...@gmail.com wrote:

 You're headed in the right direction, looking to use the composed
 relationships. But ...

 On Mon, Nov 2, 2009 at 2:19 PM, jqdur...@gmail.com wrote:

 My first exercise in saving an Address, did so without regard of the
 CompanyID. Essentially, the handler took the AddressID, located the correct
 Transfer Object, cloned it, populated, validated and saved the Address
 without any knowledge of a Company. This seemed to be working fine.


 ... if you are working with a database record that currently exists and
 has the Company relationship attached, you don't need to deal with the
 Company at all. The Address object knows what its parent Company is, and if
 you don't need to change it, then you don't have to mess with it at all.

 For a new record, you'd need to use the CompanyID to retrieve the Company
 object, then do Address.setParentCompany(myCompany), or something like that,
 before saving the Address record.

 But if the Address already has a Company, most times you can just ignore
 it. (Unless of course, you actually need the Company for another reason.)

 But why did you need to clone the object?


 Thanks,

 Tom

 Tom McNeer
 MediumCool
 http://www.mediumcool.com
 1735 Johnson Road NE
 Atlanta, GA 30306
 404.589.0560

 



 --
 Jason Durham




-- 
Jason Durham

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
transfer-dev group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~--~~~~--~~--~--~---



[transfer-dev] Re: Trying not to think in terms of tables

2009-11-02 Thread Jason Durham
Ah nuts I have a m2m between Company and Address (with a Join table).
Thus, Address isn't directly aware of Company.  My Address gets inserted but
the join table doesn't get updated.  What's the recommended way of handling
this?  Should my Decorator override the save() method in order to update the
Join table... or will Transfer maintain the Join table if access the Address
through the Company?

TIA
Jason


On Mon, Nov 2, 2009 at 2:06 PM, Jason Durham wrote:

 Ah... I hadn't considered that the Address was already aware of its
 parent.  Dealing with the Address object directly was less painful. :)

 With regard to cloning...  isn't that the only way to do it? :o)   My
 validation mechanism occurs once the Transfer Object has been populated.  I
 don't want the (potentially) invalid form data to dirty the cache until it
 has been validated.  If the object doesn't validate, I pass the entire
 object back to the form to output errors.

 Jason




 On Mon, Nov 2, 2009 at 1:46 PM, Tom McNeer tmcn...@gmail.com wrote:

 You're headed in the right direction, looking to use the composed
 relationships. But ...

 On Mon, Nov 2, 2009 at 2:19 PM, jqdur...@gmail.com wrote:

 My first exercise in saving an Address, did so without regard of the
 CompanyID. Essentially, the handler took the AddressID, located the 
 correct
 Transfer Object, cloned it, populated, validated and saved the Address
 without any knowledge of a Company. This seemed to be working fine.


 ... if you are working with a database record that currently exists and
 has the Company relationship attached, you don't need to deal with the
 Company at all. The Address object knows what its parent Company is, and if
 you don't need to change it, then you don't have to mess with it at all.

 For a new record, you'd need to use the CompanyID to retrieve the
 Company object, then do Address.setParentCompany(myCompany), or something
 like that, before saving the Address record.

 But if the Address already has a Company, most times you can just ignore
 it. (Unless of course, you actually need the Company for another reason.)

 But why did you need to clone the object?


 Thanks,

 Tom

 Tom McNeer
 MediumCool
 http://www.mediumcool.com
 1735 Johnson Road NE
 Atlanta, GA 30306
 404.589.0560

 



 --
 Jason Durham




 --
 Jason Durham




 --
 Jason Durham





-- 
Jason Durham

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
transfer-dev group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~--~~~~--~~--~--~---



[transfer-dev] Re: Trying not to think in terms of tables

2009-11-02 Thread Tom McNeer
On Mon, Nov 2, 2009 at 3:10 PM, Jason Durham jqdur...@gmail.com wrote:

  My
 validation mechanism occurs once the Transfer Object has been populated.  I
 don't want the (potentially) invalid form data to dirty the cache until it
 has been validated.


Perfectly reasonable. I just didn't follow your logic before.

Ah nuts I have a m2m between Company and Address (with a Join table).
 Thus, Address isn't directly aware of Company.  My Address gets inserted but
 the join table doesn't get updated.  What's the recommended way of handling
 this?  Should my Decorator override the save() method in order to update the
 Join table... or will Transfer maintain the Join table if access the Address
 through the Company?


Depends on your configuration, but probably, yes, if the many-to-many is set
on the Company. I think if you go through the docs on Managing
Relationships, you'll see how to set this up.

-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
transfer-dev group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~--~~~~--~~--~--~---



[transfer-dev] Re: Trying not to think in terms of tables

2009-11-02 Thread Mark Mandel
What does your company.save() do?

Mark

On Tue, Nov 3, 2009 at 10:02 AM, Jason Durham jqdur...@gmail.com wrote:

 These are the sequence of events in my handler...

 *Form is submitted*
 Create new Address object
 Populate Address object
 Validate Address object
 Retrieve Company object
 Verify Address exists in Company and copy the new Address over existing [
 oTempAddress.copyValuesTo(oCompany.getAddress(addressIndex) ]
  Save Company

 If I dump oCompany.getAddress(addressIndex).getMemento() just before the
 save of the company, I see the new data from the form.  However,
 oCompany.save() doesn't seem to save the Address I just modified.  I'm gonna
 RTFM again just in case I missed something. :)

 Jason

 



-- 
E: mark.man...@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

--~--~-~--~~~---~--~~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
transfer-dev group.
To post to this group, send email to transfer-dev@googlegroups.com
To unsubscribe from this group, send email to 
transfer-dev-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~--~~~~--~~--~--~---