pk as fk IsA can't bind reference

[prev] [thread] [next] [Date index for 2005/03/25]

From: jldommer
Subject: pk as fk IsA can't bind reference
Date: 17:19 on 25 Mar 2005
Hi all,

Thanks for the help with the issue of needing an autoincrementing pk () for IsA.  Now that I have cdbi::Oracle working, I've encountered a new problem with the create() method when using the IsA relationship, although this may just be because I have set up the db so that the pk of Artist is also the foreign key to Person.  I think this is how this should work, since it's IsA, but I noticed that someone else was recently having a similar issue, so maybe I'm wrong.  At any rate, I run into problems when I try to create a new Artist in my db with:

TestOracle::Artist->create( {
  alias => 'First',
  firstname => 'Jane',
  surname => 'Doe'
 }
);

The CPAN documentation seems to suggest that this should work.  The parent is created without incident, but when cdbi tries to generate the child I get an error that says

“Can't bind a reference (TestOracle::Person=HASH(0x8af04f8)) at /usr/lib/perl5/site_perl/5.8.0/DBIx/ContextualFetch.pm line 51.”

which I've figured out means that cdbi didn't pass the value of the parent's pk to the child, so the pk of Artist is not being given a value.  Does anyone have any suggestions/ideas about what I'm doing wrong and how I might fix it?  The code I'm working with is below.

In my base class:
use base qw(Class::DBI::Oracle);
use strict;
use warnings;

# create 'main' connection
my $dbh = TestOracle::ClassDBI->connection($dsn, $user, $password)|| die "Database connection not made: $DBI::errstr";

#adds the is_a relationship to the base class
TestOracle::ClassDBI->add_relationship_type(is_a =>'Class::DBI::Relationship::IsA');

#my subclasses
package TestOracle::Person;
use base qw(TestOracle::ClassDBI);

TestOracle::Person->table('person')|| die "Table connection not made: $DBI::errstr";
TestOracle::Person->columns(Primary => qw/personid/);
TestOracle::Person->sequence('person_seq');
TestOracle::Person->columns(Others => qw/firstname initials surname/);


package TestOracle::Artist;
use base qw(TestOracle::ClassDBI);

TestOracle::Artist->table('artist')|| die "Table connection not made: $DBI::errstr";
TestOracle::Artist->columns(Primary   => qw/artistid/);
TestOracle::Artist->columns(Others    => qw/alias/);

TestOracle::Artist->is_a( 'artistid' => 'TestOracle::Person' );

pk as fk IsA can't bind reference
jldommer 17:19 on 25 Mar 2005

Re: pk as fk IsA can't bind reference
Rhesa Rozendaal 18:01 on 25 Mar 2005

Generated at 14:42 on 11 Apr 2005 by mariachi v0.52