Re: Can an entity be promoted in single table inheritance?
Re: Can an entity be promoted in single table inheritance?
- Subject: Re: Can an entity be promoted in single table inheritance?
- From: Kieran Kelleher <email@hidden>
- Date: Thu, 01 Apr 2010 06:52:33 -0400
For sure, Roles are the way to go, especially if someone can have more than one Role (outside of the game of Chess, can a King also be a Knight? ;-) ) However if your design really has only one Role and you don't want to or can't change your database schema, you could drop the inheritance on those entities and use the Strategy Design pattern to lazily instantiate composited behaviours .... PeasantBehaviour, KingBehaviour, KnightBehaviour that all implement the RoleBehaviour interface (in American english, drop the 'u' in "behaviour".) You don't even need to change the current database. Just use the current inheritance 'type' field to map to a RoleBehaviour class..... and now the RoleBehaviour becomes an attribute. The work involved is just EOModel simplification and breaking out the behaviours into classes
YMMV, Kieran
On Mar 31, 2010, at 10:48 PM, Ramsey Lee Gurley wrote:
> I can't see this being possible in Vertical or Horizontal, but with single table... could the qualifying attribute be updated to 'promote' an entity to a new class? Let's say we have we have an abstract Person entity with three subclasses, Peasant, Knight, King. If I wanted to promote a knight to king, is it possible to simply update my type attribute from knight to king and EOF will start treating that record as a king instead of a knight? I would assume I would need to invalidate the existing knight object after saving changes so it could be refetched as a king... and if I had multiple instances, I'd need to invalidate it in those instances too... but is it possible? Or will EOF just flip out in the saveChanges() and refuse to do it?
>
> Just an academic question, of course (^_^)
>
> Ramsey _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden