Greetings zigdon,
I'm still learning CBDI myself, so I don't know how helpful this will be. However, here's what I've come up with. I think the problem is with your has_many definitions for Org and PartType. The two lines should be more like:
__PACKAGE__->has_many('PartTypes' => 'MyCDBI::PartType', 'typeid');
To solve the problem, I had to rewrite ever so slightly some of your conventions (to help me mentally understand things because I'm still learning CDBI myself), so you'll want to translate this code back. However, here's the final code that does appear to work for me...
#!/usr/bin/perl
use strict;
use warnings;
package MyCDBI;
use base 'Class::DBI::mysql';
__PACKAGE__->connection('dbi:mysql:cdbi', 'gryphon', 'PASSWORD');
package MyCDBI::Org;
use base 'MyCDBI';
__PACKAGE__->set_up_table('org');
__PACKAGE__->has_many('PartTypes' => 'MyCDBI::PartType', 'typeid');
package MyCDBI::PartType;
use base 'MyCDBI';
__PACKAGE__->set_up_table('parttype');
__PACKAGE__->has_a('orgid' => 'MyCDBI::Org');
__PACKAGE__->has_many('PartTypes' => 'MyCDBI::OrgPart', 'typeid');
package MyCDBI::OrgPart;
use base 'MyCDBI';
__PACKAGE__->set_up_table('orgpart');
__PACKAGE__->has_a('typeid' => 'MyCDBI::PartType');
package main;
my $org = MyCDBI::Org->create({ orgid => 1 });
my $pt1 = MyCDBI::PartType->create({ typeid => 1, orgid => $org });
my $pt2 = MyCDBI::PartType->create({ typeid => 2, orgid => $org });
my $op1 = MyCDBI::OrgPart->create({ typeid => 1, typeid => $pt1 });
my $op2 = MyCDBI::OrgPart->create({ typeid => 2, typeid => $pt1 });
my $op3 = MyCDBI::OrgPart->create({ typeid => 3, typeid => $pt2 });
my $op4 = MyCDBI::OrgPart->create({ typeid => 4, typeid => $pt2 });
$org->delete;
And just to make sure I cover my assumptions, here's the create SQL for the database...
CREATE TABLE org (
orgid tinyint(3) unsigned NOT NULL auto_increment,
PRIMARY KEY (orgid)
) TYPE=MyISAM;
CREATE TABLE orgpart (
opid tinyint(3) unsigned NOT NULL auto_increment,
typeid tinyint(3) unsigned default '0',
PRIMARY KEY (opid)
) TYPE=MyISAM;
CREATE TABLE parttype (
typeid tinyint(3) unsigned NOT NULL auto_increment,
orgid tinyint(3) unsigned default '0',
PRIMARY KEY (typeid)
) TYPE=MyISAM;
I hope this helps. I'm still struggling with CDBI in hopes that eventually it will be worth it.