I am a new user (as of about 2 hours ago).  I have two tables that have a
one-to-one relationship with a third (so, of course, there is a one-to-many
from the third to the other two).  The code looks like below.  However, I
get the following error message on compile and I do have foreign keys
present in the g_alias and g_refseq tables.  I can't figure out what I am
doing incorrectly.  Any help?

Thanks,
Sean


Could not auto-generate foreign keys for class AnnoDB::Model::Gene::Alias -
Missing or invalid key name '' for foreign key generated in
AnnoDB::Model::Gene::Alias for AnnoDB::Model::Gene::Main at
/Library/Perl/5.8.6/Rose/DB/Object/Metadata/Auto.pm line 432.
 at lib/AnnoDB/Model/Gene/Alias.pm line 14
Compilation failed in require at rosetest.pl line 5.
 at rosetest.pl line 5
        main::BEGIN() called at lib/AnnoDB/Model/Gene/Alias.pm line 5
        eval {...} called at lib/AnnoDB/Model/Gene/Alias.pm line 5
BEGIN failed--compilation aborted at rosetest.pl line 5.
 at rosetest.pl line 5

A simple test of the packages:
#!/usr/bin/perl
use strict;
use lib './lib';
use AnnoDB::Model::Gene::Main;
use AnnoDB::Model::Gene::Alias;

my $genes = 
AnnoDB::Model::Gene::Main::Manager->get_gmain_iterator(query=>[symbol =>
'BRCA1']);

while (my $gene = $genes->next) {
  print join("\t",$gene->symbol, $gene->description)."\n";
  foreach ($gene->refseqs) {
    print "     ".$_->refseq."\n";
  }
}


package AnnoDB::Model::Gene::Alias;
use base qw(AnnoDB::Model);

__PACKAGE__->meta->table('g_alias');
__PACKAGE__->meta->relationship
  (
   gene => {
        type => 'one to one',
        class => 'AnnoDB::Model::Gene::Main',
        column_map => {gene_id => 'gene_id'},
       },
  );

__PACKAGE__->meta->auto_initialize();


package AnnoDB::Model::Gene::Alias::Manager;
use strict;
use Rose::DB::Object::Manager;
our @ISA = qw(Rose::DB::Object::Manager);

sub object_class{'AnnoDB::Model::Gene::Alias'};

__PACKAGE__->make_manager_methods('galias');

1;

package AnnoDB::Model::Gene::Refseq;
use base qw(AnnoDB::Model);

__PACKAGE__->meta->table('g_refseq');
__PACKAGE__->meta->relationship
  (
   gene => {
        type => 'one to one',
        class => 'AnnoDB::Model::Gene::Main',
        column_map => {gene_id => 'gene_id'},
       },
  );

__PACKAGE__->meta->auto_initialize();


package AnnoDB::Model::Gene::Refseq::Manager;
use strict;
use Rose::DB::Object::Manager;
our @ISA = qw(Rose::DB::Object::Manager);

sub object_class{'AnnoDB::Model::Gene::Refseq'};

__PACKAGE__->make_manager_methods('grefseq');

1;



package AnnoDB::Model::Gene::Main;
use base qw(AnnoDB::Model);

__PACKAGE__->meta->table('g_main');

__PACKAGE__->meta->relationships
  (
   aliases => 
   {
    type => 'one to many',
    class => 'AnnoDB::Model::Gene::Alias',
    column_map => {gene_id => 'gene_id'}
   },
   refseqs => 
   {
    type => 'one to many',
    class => 'AnnoDB::Model::Gene::Alias',
    column_map => {gene_id => 'gene_id'}
   },
  );
__PACKAGE__->meta->auto_initialize();


package AnnoDB::Model::Gene::Main::Manager;
use strict;
use Rose::DB::Object::Manager;
our @ISA = qw(Rose::DB::Object::Manager);

sub object_class{'AnnoDB::Model::Gene::Main'};

__PACKAGE__->make_manager_methods('gmain');

1;



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to