Need to inherit from a domain class that is not persisted to the database

2 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    Apr 2013

    Posted 23 Oct 2013 Link to this post

    Hi There,

    Been looking for ages on a solution to this. 

    Basically I would like to have a set of domain classes that inherit from another domain class where none of these classes will be tables in databases but instances will be created in memory/retrieved from the cache.

    The problem im hitting is when trying to define a discriminator column the mappings editor does not seem to allow me to select a discriminator column as it only looks at columns that are mapped to a db.

    Is this possible???

  2. Kristian Nikolov
    Kristian Nikolov avatar
    206 posts

    Posted 24 Oct 2013 Link to this post

    Hello Chris,

    It is possible to inherit from classes which will not be persisted to the database. The way to achieve this is to use Horizontal Inheritance. It can be specified for the parent classes in the inheritance graph. Classes marked for Horizontal Inheritance will not have tables in the database and thus their instances cannot be persisted but can be instantiated. You can model Horizontal Inheritance in the following way:

    I hope this helps.

    Kristian Nikolov
    OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
  3. DevCraft banner
Back to Top