On 9/8/06 11:17 PM, Clayton Scott wrote:
> sub plural_to_singular { $_[1] }
> sub singular_to_plural { $_[1] }
I'm not sure what you're aiming for with that bit, but it's what's causing
the conflict (albeit in a roundabout way). If you just want the table names
to be singular, set the tables_are_singular() convention manager attribute
to true. (This attribute was added recently, so upgrade if you don't have
the latest RDBO version.) You can do this in a CM subclass by overriding
tables_are_singular() to always return true, or you can do it right from the
loader with no custom CM class at all:
$loader = Rose::DB::Object::Loader->new(...);
$loader->convention_manager->tables_are_singular(1);
$loader->make_classes;
When I ran that against your tables (modified to give the first two tables
primary keys, which I'm assuming you forgot to copy/paste in your original
email) I got classes with relationships like those shown below, which I
believe is what you want.
package Person;
...
relationships =>
[
phones =>
{
column_map => { person_id => 'id' },
foreign_class => 'Phone',
map_class => 'PersonPhoneMap',
map_from => 'person',
map_to => 'phone',
type => 'many to many',
},
],
);
package PersonPhoneMap;
...
foreign_keys =>
[
person =>
{
class => 'Person',
key_columns => { person_id => 'id' },
},
phone =>
{
class => 'Phone',
key_columns => { phone_id => 'id' },
},
],
);
package Phone;
...
relationships =>
[
persons =>
{
column_map => { phone_id => 'id' },
foreign_class => 'Person',
map_class => 'PersonPhoneMap',
map_from => 'phone',
map_to => 'person',
type => 'many to many',
},
],
);
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object