[Dbix-class] table-per-subclass - how it works?

Bob MacCallum uncoolbob at gmail.com
Mon Jun 18 10:45:39 GMT 2012


Just wanted to make sure the OP had seen
http://search.cpan.org/~syber/DBIx-Class-DynamicSubclass-0.03/lib/DBIx/Class/DynamicSubclass.pm

It looks like once you have your subclasses working (don't ask me
how), you can make sure they inflate from the DB into the correct
class using

__PACKAGE__->typecast_column('defining_column');

where defining_column I guess would be the primary key (of the base
class table).


On Mon, Jun 18, 2012 at 9:40 AM, Patrick Meidl <patrick at pantheon.at> wrote:
> On Mon, Jun 18 2012, Alexander Hartmaier <alexander.hartmaier at t-systems.at> wrote:
>
>> If I understand you correctly, you want to define a Perl object that
>> doesn't directly relate to one table but to column from multiple tables?
>> DBIC result objects always represent exactly one table with all its
>> columns, primary and unique keys and relationships.
>> What you want is a 'business' layer on top of that which you can define
>> however you like, for example with Moose, that uses the DBIC objects so
>> you don't have to deal with SQL.
>
> exactly. in java lingo: the DBIC Result object is the equivalent of a
> DAO (data access object), not a business model. of course, you can (with
> both Hibernate and DBIc) use your DAO as your business model, but this
> is not a very clean design.
>
> that said, Hibernate *is* slightly more flexible regarding the mapping
> of objects to tables. you can achieve similar results in DBIc with a
> little bit of hand coding in the Result classes (as was pointed out by
> other posters already), but it will get a bit quirky.
>
> in my experience, it's better to do things the way your framework
> intended them, rather than trying to bend the framework to work the way
> another framework does, even if you think the other design is nicer.
>
> HTH
>
>    patrick
>
> --
> Patrick Meidl ........................ patrick at pantheon.at
> Vienna, Austria ...................... http://gplus.to/pmeidl
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk



More information about the DBIx-Class mailing list