This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm using the latest nightly build, and I was hoping to use ConcreteTableInheritance. However, it doesn't seem to support synchronizing ConcreteTableInheritance with the database. Am I doing something wrong or is this simply not supported (yet?)? Robert |
|
|
That should be supported in the current nightly builds, with the constraint that it requires that only leaf classes be concrete (i.e. CTI base classes must be marked as abstract). Assuming that your base classes are marked as abstract, could you tell us what error you are seeing? |
|
|
Fantastic - I hadn't realized that the base class needed to be marked as abstract. Unfortunately, I just switched to single-table mode and generated the database. So I've now deleted all the tables from my database and switched back to ConcreteTableInheritance. I have set the "Inheritance" property of my base entity class (called, "BaseEntity") to "Abstract" in the designer. It now attempts to generate the code. However, in the "Update Database" there is no indication that it will create the "BaseEntities" table. When I press "Ok" I get an error that "The following updates could not be carried out: Add table Tags to the database - Foreign key 'FK_Tabs_BaseEntity_3E23F9C' references invalid table 'BaseEntities'". It seems that because it's abstract it doesn't create a database table for it, but it still expects such a table.
|
|
|
You're right, because it's abstract it doesn't create a table for it. (And you're also right that we need to update the docs -- this is one of those things that tends to slide in the nightly builds! There is some documentation at http://www.mindscape.co.nz/blog/index.php/2009/03/01/getting-started-with-inheritance-in-lightspeed/ but it's fairly basic...) I think the reason it is looking for such a table is because you have an association to the base entity type: this would of course be represented by a foreign key to the base table and the base table doesn't exist. Unfortunately, associations to CTI base classes are not supported in LightSpeed. You must define the associations to the derived classes, or use STI instead. For more info see http://www.mindscape.co.nz/blog/index.php/2008/11/03/inheritance-in-lightspeed/ and especially the discussion of associations in the section on Single Table Inheritance. |
|
|
Thank you for the link, and yes, I do have associations to the base class entity. We're going to have many, many entities, and every non-trivial entity in the model will need to have a relationship with the security table, and the tags table, and the User that owns/created the entity, etc. With over 15 such entities it seems that single-table inheritance is really not appropriate. However, it seems that to use concrete inheritance (or no inheritance) we're going to need to create/duplicate all the relationships (to the security table, etc) manually. Neither approach is really great, do you have any suggestions? Robert |
|
|
Hi Robert, Depending on your application design it sounds like you may need to have them applied to each table. However is it possible for you to infer those relationships rather than having them directly referenced? For example can you hold a weak reference to the object identifier of your foreign entity instances within the security table and then manually load the associated security objects via your security components as required?
Jeremy
|
|
|
Thanks! |
|