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
|
Hi, here is a problem I am having with inheritance.
I have a base class named Consumer, and it has a string field named "Name". I have a class that derives from Consumer named Package. When I try to query for all Packages, it throws a MySql exception saying that the column "package.name" doesn't exist in the database. Well it's not supposed to exist in the database, the name column should only be at the Consumer table, not duplicated in the Package table.
What's going on with this? Btw I am trying to use concrete table inheritance. |
|
|
In concrete table inheritance, the database table includes columns for ALL properties in the mapped class, including properties inherited from a base class. Fowler has a picture. It sounds like you want to use "class table inheritance," where each database table includes columns only for properties declared in the mapped class -- and is joined at query time to the base class tables to access the properties declared in base classes. This is not currently supported in LightSpeed. (Single table inheritance would put the Name column into the Consumer table, but would also require all Package properties to be in the Consumer table as well.) See http://www.mindscape.co.nz/blog/index.php/2009/03/01/getting-started-with-inheritance-in-lightspeed/ and http://www.mindscape.co.nz/blog/index.php/2008/11/03/inheritance-in-lightspeed/ for more info about the inheritance options and how classes map to database tables under each. |
|
|
Oh, I apologize, I didn't know what it was called :)
That would be great if you could add it, it seems like a clean, normalized way to represent inheritance (as opposed to the other 2 methods which are already supported). Please add it when possible, it would really add value to your product. Thank you |
|
|
We did investigate implementing class table inheritance a month or so back, but with our current design it got really complex really quickly. (Performing the necessary joins on SELECTs was nasty, but performing the necessary fan-out to the multiple tables on INSERTs and UPDATEs defeated me completely *grin*.) Jeremy is working on some core changes for LightSpeed 3 that might
make it easier for us to tackle this in the post-3.0 timeframe, but I
expect it would still be a fairly major chunk of work for us, and one we'd need to balance against other priorities. However, we're aware that several customers would like to have this option so it is definitely on the wish list. Thanks for the feedback! |
|