Share descendant's table mapping

4 posts, 0 answers
  1. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 09 Nov 2011 Link to this post

    Hi.

    I would love to see the following functionality in future versions:

    Background:
    I have a base abstract perstent class with identity and version fields (ID, Version), which is mapped to a table 'PersistentObject'. All my persistent classes derives from this class, which means they all put an entry into this table on creation.

    This table will of cource then grow very large over time and i would like to use separate tables for separate classes, with their own version/id columns.

    One way to achieve this is to declare the class fields protected and do the mapping in the descendant classes, but this means exposing direct write access to fields which should alwas be read-only to both users and developers, and this poses a high risk. It also requires mapping be set up for the same fields in every class, which is error prone and time consuming.

    What I would like to do, is what I've seen with another ORM vendor, to map the fields in the base class, but specify on a class (field even) that fields mapped in this class should use the table mapped by it's descendants. Recursively of course, should the descendant also specify this behaviour.

    Thanks

    Pål
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 14 Nov 2011 Link to this post

    Hello Pål,

    I believe that the horizontal inheritance feature should allow you to achieve the goal that you have described in your last post. If you allow OpenAccess to automatically do the mapping for you, you will not have to specify mapping for your properties on each class separately.  Specifying the mapping on class level is also possible if necessary.

    Best wishes,
    Zoran
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

  3. DevCraft banner
  4. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 14 Nov 2011 Link to this post

    Hi.

    Can you show me how to implement this using the 'classic' mapping model please?

    Thanks

    Pål
  5. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 14 Nov 2011 Link to this post

    Hello Pål,
    Please add the horizontal setting to your mapping like this:
    <class name="HorzBaseFilePKFields">
      <extension key="db-inheritance" value="horizontal" />
    </class>


    Regards,
    Jan Blessenohl
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

Back to Top