Tom,
This is a basic problem with the current EJB spec. I don't know what the future
holds. For now we handle this with a combination of a mapping layer which
supports polymorphism and using the often mentioned pattern (whose name I
forgot) where entity beans are only accessed via a session bean. We then hide
the ugly details of which entity bean to use from the client in the session bean
code.
Because the mapping layer supports polymorphism, we can access and edit all
specializations of person in a generic person bean. Granted, some of the
specialization may not be supported in the interface. That turns out not to me a
major problem in the overall scheme.
I also don't spend a lot of time trying to make every session bean polymorphic.
I make the domain objects polymorphic and make the beans polymorphic only where
it is called for by the user interface. Since we can use a person bean when
needing only general person data (name, birthdate, etc...) there is less of a
need for polymorphic beans than I orginally thought.
--Victor Langelo
Tom Lepski wrote:
> Hi Kurt,
> I understand your Collection analogy but I think this is really a legitmate
> demand. For eg. in a system there could be Persons, Managers and Techleads.
> Now, it is quite reasonable to retrieve all the Persons in one go and then
> depending on the person perform activities. So there have to be different
> entities because operations like manage() cannot be provided in Person bean.
>
> But as I write this, I got another idea.
> Support all the methods in Person (actually have just one kind of entity
> bean which has superset of all the attributes) and also have a tag field
> telling whether it is a Person or Manager etc. Now depending on this tag,
> call the appropriate methods. If you call manage() on a bean that has the
> tag value of Person, throw some runtime exception!
>
> Please give your comments on this. I am sure many of the projects involving
> EJBs must have ran into this kind of situation.
>
> Please help,
> -Tom.
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".