On 10/13/06, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:
> On Oct 13, 2006, at 4:09 PM, John Siracusa wrote:
>> Then why not just do this:
>>
>>     $a = A->new(id => 123);
>>     $b = B->new(id => 123);
>>     $a->b($b);
>>
>>     $a->save; # save A and its associated B
>
> That's actually exactly what I wanted.
> I couldn't figure out if rose supported that or not.

It does :)  Read up on the "get_set_on_save" variants of the methods
created for the various relationship types.  In this case, a
one-to-one relationship, the default automatically created method
types:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/OneToOne.pm#default_auto_method_types

are "get_set_on_save" and "delete_on_save". Looking at the method map:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/OneToOne.pm#METHOD_MAP

shows that methods of the "get_set_on_save" method type re created by
Rose::DB::Object::MakeMethods::Generic, specifically its
"object_by_key" method maker, using the interface "get_set_on_save"

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/MakeMethods/Generic.pm#object_by_key

Reading the documentation for the "get_set_on_save" interface reveals
the details of the method behavior.  An excerpt:

"The object will be saved into the database when the "parent" object is saved."

And there you have it :)  I know it's quite a trip through the docs
(there are links to click on, at least) but modular architecture tends
to lead to modular documentation.

-John

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to