Hi,

I'm trying to rename auto generated relationship to a more convenient
name. I checked the docs and the following (rather clumsy) code was
expected to do the job:

package My::Category;

use base 'My::Object';

__PACKAGE__->meta->table('categories');
__PACKAGE__->meta->auto_initialize;

# get the relationship I want to rename
my $cat_rel = __PACKAGE__->meta->relationship('categories');
# remove it
__PACKAGE__->meta->delete_relationship('categories');
# rename it
$cat_rel->name('parent_category');
# add new relation
__PACKAGE__->meta->relationship('parent_category', $cat_rel);

Using My::Category->meta->perl_class_definition I inspected the
relation ships and they looked OK:

...
relationships => [
   parent_category => {
      class       => 'My::Category',
      key_columns => { id => 'parent_id' },
      type        => 'one to many',
   },
....


However, when I try to use the new method "parent_category", I get this error:

Can't locate object method "parent_category" via package
"My::Category" at /usr/lib/perl5/site_perl/5.8.4/Rose/DB/Object.pm
line 1287

It seems adding new relationship doesn't create the new methods so I
tried manually calling make_methods after renaming the relationship
but but I got this error:

Error:  Cannot create method My::Category::add_categories - method
already exists at
/usr/lib/perl5/site_perl/5.8.4/Rose/DB/Object/Metadata/MethodMaker.pm
line 420

It seems that the method maker still uses the previous name
("categories") to create the methods.

My questions are:
(a) is there a simpler way for renaming a relationship w/ building new methods
(b) if not (a), how can I make relationship to create methods with
different name

Thanks in advance!

-- Svi


-------------------------------------------------------------------------
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