On 2009-11-13 15.41, Jacek Sokulski wrote:
Hello,
Some questions on modelling entities:
Suppose I have Employee and Manager entities and Manager is Employee
with additional behaviour and/or state.
1. Can I promote Employee to Manager? I.e. can I take an Employee object
and add to it Manager roles (during runtime, entity creation)?
2. From DB point of view, is a Manager an Employee? e.g. can I construct
a query for all Employees that are Managers or Traders?
uow.get(Employee.class, <ID>) will it return Manager object or Employee
not castable to Manger?

Employee, Manager and Trader are roles, not entities. If you have dynamism (i.e. these roles can come and go), then I would suggest having PersonEntity instead which has Employable, Managerable and Traderable (bad words but hope you get the idea) as role interfaces. It is static that a Person *can* be any of these things, but the *actual* roles played by any particular instance at any particular time can change. The Employee/Manager/Trader roles can then either be values or entities, depending on what you want to accomplish.

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to