Forward-Mapping inheritance question

10 posts, 0 answers
  1. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 16 Oct 2010 Link to this post

    I'm playing with inheritance and Forward-Mapping, and while it does seem to work, I'm getting some errors.

    I'm trying to create a base class that all classes will inherit that contains the following fields:
    • Id (this would act as the primary key property for all subclasses)
    • Notes
    • rowversion

    So my Person class would inherit this classe to obtain the use of Id, Notes and rowversion.  All the other classes would do the same.  Is this a good practice?

     

    I've attached a jpg that shows an example I'm working on to see how inheritance works with OpenAccess.  I can unit test the classes properly, but I get the errors that say something about the Indentity Type is not compatible etc.

    My questions are:
    1. Can I continue in this type of direction with my classes and have them create tables properly?
    2. Is this the best way of doing this?
    3. Are there other resources about how to work with inheritance than this link?  Any videos examples?  I haven't seen any.

    Thanks.

  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 17 Oct 2010 Link to this post

    Hi King Wilder,

    I think it is very good practice to have an abstract base class to hold those values (id and version). The inheritance strategy you are doing is what is called horizontal mapping in OpenAccess terms.
    I have written a blog post about it.. although it is targeting the classic approach of OA. You might get some ideas of how to handle it.

    Doing the above will give you no table for the MetaBase and the fields of MetaBase present in all subclasses and columns in tables for those classes.

    Regards

    Henrik
  3. DevCraft banner
  4. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 17 Oct 2010 Link to this post

    Henrik,

    Thanks for the response.  I read your blog post and it helps a lot.  I'm just starting with OA and I've been testing it with the Visual Designer.  I'm creating the entities on the visual designer surface and creating the inheritance from there.  Since I'm getting those errors about the Indentity Type fields, is that due to my not mapping anything to a database schema yet?

    I will try creating a schema using the various mapping patterns, Flat, Vertical, Horizontal, etc and see how they differ.

    I'm glad I'm going in the right direction.  I'll change my base class to abstract.

    Thanks,

    King Wilder
  5. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 17 Oct 2010 Link to this post

    I kind of hit a wall when trying to create an association between objects.  I didn't get a relationship dialog that allowed me to do any relating.

    1. Is this not possible when forward-mapping?
    2. How do I relate objects that inherit from a base class that contains the common primary Id field?  Is there a video on this somewhere?

    Also when I generated the database tables from my model, the tables generated weren't generated as I had hoped.  I've attached a jpg of my generated tables.

    The columns aren't generated the way I would like.  Is there a way of getting them the way I want or is the result something OA needs and I don't have to worry about it?  For instance, you'll notice in the jpg, that the "rowversion" property from the base class is generated as "rowversion1", and then theres an extraneous column called "i_d" in all tables.  What's this for?

    I'm not really complaining, I'm just curious.

    Thanks,

    King Wilder

  6. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 18 Oct 2010 Link to this post

    King,

    Did you forget the .jpg attachment. I am not able to find it.

    I don't see why you should not be able to associate subclasses of MetaBase with each other... Unless there's something wrong with the domain model. Remember that it is the MetaBase that should be marked with the Horizontal mapping strategy. How does the generated class look like?

    Regards

    Henrik
  7. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 18 Oct 2010 Link to this post

    Yes I did forget to attach the files.  My bad.  Here they are.

    I did mark the base class as horizontal and it seemed to create the four subclasses objects and tables, but didn't carry across the relations.

    Updated Note: sorry I attached a wrong version of the original objects, so disregard it. Thanks.
  8. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 18 Oct 2010 Link to this post

    Hi there,

    I cannot see (from the .jpg) you attached what relations it should carry, since there are no relations.
    As for the "extra" ids, you have to define for the subclasses to use the Id and Rowversion from the MetaBase class instead of having their own.
    Maybe you can attach the generated classes?

    I don't know what version of OA you're using, but an internal build (latest) has been released and there are some issues regarding forward mapping and horizontal inheritance mapping.
    Maybe you should try it it out.

    Regards

    Henrik
  9. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 19 Oct 2010 Link to this post

    Henrik,

    Thanks for helping me out by the way.

    I've created a short 10-minute screencast that shows how I proceed to create a forward-mapping project.  Everything goes well for a while, but in my last attempt, I was able to set my subclasses as "Vertical" mapping, and this time I can't.

    http://www.screencast.com/t/iohvFwf5v

    You'll also see that I can't generate a database from my model because it continually asks me to "Rebuild" the application.

    I've read a lot of documentation on OA and reverse-mapping isn't a problem, but I thought I'd give forward-mapping a try and haven't had much luck.  Do you know if there are any good screencasts on forward-mapping with inheritance?

    One of the things I don't like is how OA generates the tables.  It adds weird tables (voa-keygen) and weird columns into the tables.

    Anyway, I hope you can see some of the issues I'm going through with forward-mapping.  I'm sure it works, but I haven't gotten it to work for me yet.

    BTW, I can't show you my last attempt since I deleted the VS project and database.

    Thanks,

    King Wilder
  10. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 20 Oct 2010 Link to this post

    Hello King Wilder,

     We are glad to know of your interest about our product. Let me shed some light on the situation you are facing at the moment: The inheritance support in the Visual Designer was not fully "baked"(e.g. not all possible scenarios were possible to configure) for the version that you are using at the moment - Q2 2010. However we have addressed all the inheritance issues for the upcoming Q3 2010 release which will be available in the first half of November. I can assure you that there will be video resources for all of the inheritance set-ups and through documentation for them as well. 

    The "weird" tables that you can see created by OpenAccess - namely voa_keygen get created because you have left some classes without specifying their identity members and identity mechanism. OpenAccess automatically uses internal identity mechanism that gets tracked in this table. If you want to avoid this, please make sure that you specify the identity for all of your classes.

    Anyway, if it is not too urgent for you, I would suggest you to be patient until the Q3 release where we will make sure that the opportunities for mistakes of our customers will be limited to maximum.

    Kind regards,
    Zoran
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. King Wilder
    King Wilder avatar
    240 posts
    Member since:
    Oct 2007

    Posted 20 Oct 2010 Link to this post

    Zoran,

    Not a problem.  I realize I was stumbling around on my own and I had a feeling some features weren't yet available.  I'm in no hurry to use this feature, I was just playing around.

    My use of "weird" was just my ignorance to the understanding of how to make this work the way I wanted.  So far I'm liking OA and especially the Fetch Plans.

    I'll come back and investigate forward-mapping again as you add more features.

    Thanks,

    King Wilder
Back to Top
DevCraft banner