Thanks for your comment, Richard. My main interest of the bean
inheritance was to base
dependant objects on an abstract base class (in this example food based
on a animal reference), but
if this is not possible, I have to find some other solutions.
So as I understood the EJB concept, the main purpose of the entity beans
is the object oriented representation
of the database tables (and some business methods), but the user
interface should be build in the session
beans. From my point of view it would make sense that the attributes of
the entity bean can differ from the one's 
in the attributes of the value object (e.g. to hide some information
from the user). Can you second that? Or should
there always be a match for some purpose?



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard
Kunze
Sent: Tuesday, December 09, 2003 12:18 PM
To: Matthias Bohlen; 'Thorsten Lamby'
Cc: [EMAIL PROTECTED]
Subject: Re: [Andromda-user] Next Release


Hi Thorsten, Matthias,

On Monday 08 December 2003 23:20, Matthias Bohlen wrote:
> Hi Thorsten,
>
> > either a cat or a dog. How can I get out of it?
>
> Well :-) you simply won't get out of it with EJBs. They are simply not

> designed for true inheritance.
>
> > But why is the ejb inheritance support in the new version if it 
> > makes
>
> no sense?
>
> > Isn't it useful in some cases even it is not the pure object 
> > oriented
>
> design?
>
> Richard implemented inheritance purely on the Java level. One bean 
> inherits from another and aggregates all its superclass attributes 
> into the same database table (Richard, is that correct?).

Not quite. It inherits the attributes from the super class, but they are

stored in the database table corresponding to the concrete bean. For the

cat-dog-animal example, all of the CAT, DOG and ANIMAL (if AnimalBean's
not 
an abstract super class but a concrete bean as well) will have a NAME
column 
storing the name of the pet.

Storing the attributes in the super class table isn't easily possible
with 
CMP. The only way I can think of is a hidden CMR relation to the parent,
and 
delegating the inherited attributes to the parent instance, but this
would 
make it impossible to use the inherited attributes in an EJB query. 

Implementing inheritance is possible with BMP, but if you're going to 
implement the persistence by hand anyway, you can just as well use a 
different persistence layer and not have to reinvent that particular
wheel...

> It is just a shortcut to simplify programming a little.

It's a little bit more than that, actually. A CatBean and a DogBean that

derive from AnimalBean *are* instances of AnimalBean for all intents and

purposes. They implement the common entity interface, have all the
attributes 
(and business methods, for that matter) of AnimalBean and so on.

The only thing that is not inherited (and can't really be with CMP
beans) is 
finder methods and container managed relations. It's not possible with
EJB 
semantics to have a finder on AnimalBean that returns both cats and
dogs, and 
it is not possible to have a container managed relation to an AnimalBean
that 
relates to anything other than "generic" animals.

> OK, so I'd say: do not try to make inheritance REALLY work with EJBs. 
> You'll spend about 6 months and end up with a very ugly solution. Use 
> an O/R mapper and you'll be happier! :-)

I'll second that. If you need real support for inheritance, ditch EJB
entity 
beans and go with a different persistence layer. 

> P.S.: Richard, how about using brute force and encoding the type of 
> the subclass in the primary key of the entity?

Sure - I'll go work on it as soon as you tell me how to implement
"select 
OBJECT(o) from MyDerivedBean o" so that it won't find the data for other

classes that are persisted in the same table ;-)

Bye,

Richard 
-- 
Richard Kunze 

[ t]ivano Software, Bahnhofstr. 18, 63263 Neu-Isenburg
Tel.: +49 6102 80 99 07 - 0, Fax.: +49 6102 80 99 07 - 1
http://www.tivano.de



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Andromda-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/andromda-user

Reply via email to