G'day. I am just starting out with RDBO, having previously used
Class::DBI a fair bit. I have a couple of questions...
In my trial project I need to establish a (well, two, actually)
self-referential many-to-many relationship on one of my tables.
The table structure is trivial:
create table foo ( id bigserial primary key );
create table foo_parent (
child bigint not null references foo (id),
parent bigint not null references foo (id),
primary key (child, parent)
);
I also declare the relationships as indicated by the tutorial:
in FooParent:
__PACKAGE__->meta->foreign_keys(
child => { class => 'Foo', key_columns => { child => 'id' } },
parent => { class => 'Foo', key_columns => { parent => 'id' } }
);
in Foo:
__PACKAGE__->meta->relationships(
parents => { type => 'many to many',
map_class => 'FooParent',
map_from => 'child',
map_to => 'parent'
},
children => { type => 'many to many',
map_class => 'FooParent',
map_from => 'parent',
map_to => 'child'
}
);
The rest of the classes are dead-trivial - specify the package, use my
base object, declare the table, columns and pkey, and call the
initialize method. Stock stuff from the tutorial, and the classes that
/do/ work match it exactly.
The error I get on trying to load the object is:
Cannot create method FooParent::child - method already exists at
/usr/share/perl5/Rose/DB/Object/Metadata/MethodMaker.pm line 379
If I comment out the foreign_keys code in FooParent then the error goes
away but, as I understand it, that will result in non-working code...
I suspect that there is something obvious and silly that I have missed;
I certainly don't feel I understand the 'many to many' relationship
declaration well, despite reading the documentation thoroughly.
If anyone can point me to where I have gone wrong, or even the general
area of where the error is caused, that would be great.
Thanks,
Daniel
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object