Reading your reply, I realise that I missed out a key point. Very sorry. I was writing to the poop group too and assumed too much immersion in Class::DBI.

__PACKAGE__->has_many( 'sessions', 'Super::Session', 'person' );

The has_many() class method here creates two object methods: a sessions() method in this class, which returns a list of session objects, and a person() method in Super::Session, which returns a single person object. It's just a way of representing a one to many link.

As you say, everything is fine in the class and subclass presented here: you get what you ask for according to where you ask for it.

Where it breaks down is in the method created in the foreign class. It thinks it should return an object of Super::Person, since that was the package from which it was created, but in fact I want an object of Sub::Person, since that was the subclass which caused - but did not make - the call to has_many. grrr.

I'm beginning to think that Class::DBI's inheritance is just broken here. Or, as you say, my thinking is broken here. Guess I need to find another way.


In reply to Re: Re: __PACKAGE__ in subclass by thpfft
in thread __PACKAGE__ in subclass by thpfft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.