Hi!

It is hard task mainly beacause of finder methods.  The main problem is
that
finder methods do return references to subclasses so if you have two
entities:
MyBaseEntity bean and MyDeriverdEntity, findByPrimaryKey(pk) will return
an
instance of MyBase even if pk is of MyDeriverdEntity.

There are several solutions possible.

1. Make the bean CMP and hack up custom container. It is the way we
currently
   proceeding.  We taken JOnAS (http://www.bullsoft.com/ejb/) as base. I
think
   it is very safe way from EJB 2.0 compatibilty point of view. Because
   everythig related to finder methods is done in container.

2. Make wrappers over home interfaces. These wrappers checks all
collections
   and references returned from finder methods and substitute correct
ones
   if type is incorrect. This path looks harder, and by my estimation
require more
   dark magic then previous one. For exmple if you modify found object,
container
   may decide save to save entity of correct type then entity with the
same
   identity of base type with all fun related to it.

3. You may try to get SUN to add support for inheritance support for
finder methods
   for BMP in EJB 1.1 ;-). I failed this variant, maybe you will more
successfull.
   I'm repeating my latest proposal:

   a) add deployment attribute indicating that one entity bean is
subclass of another.
   b) add class javax.ejb.KeyHomePair with two attributes primaryKey:
Object and
      home : EJBHome to javax.ejb package.
   c) add property to finder method in deployment descriptor with
indicate that
      this finder method can return instances of subclass of this bean.
   d) if finder method is marked as such, then this finder method return
instances
      of KeyHomePair instead of primary keys.

   I think that this proposal is easily implementable especially
considering that in
   EJB 1.1 stability of references to home interfaces and other entity
beans is
   guaranted. So bean developer always can use references provided by
container for
   this purpose.

4. If you do not need finder methods at all except for restoring
references.
   It is very possible to implement everyting in 1.1 and I think that
this
   implementation will work in the most of servers. Just keep some sort
of
   type identifier in all places where you are keeping the primary key.

5. Use some custom solution for specific EJB server. I heard
(unconfirmed)
   that weblogic have one, which is very similar to my proposal.

6. Of cause there may be (is) one that I missed. If you will became
aware of
   one, please notify me.

Good luck with any variant you choose, but I especially like if you will
succeed in third.

Constantine

Lisa Retief wrote:
>
> Hi,
>
> I am needing to implement inheritance using BMP Entity EJB's. I understand
> that there will be some clear specification of how to go about this in the
> EJB 2.0 spec, but unfortunately I can't wait that long, and was wondering if
> there were some good guidelines out there. If this has been discussed here
> before, can someone point me to the archive URL? Is there some other
> documentation or EJB spec 2.0 preview? Do any of you have experience in this
> area?
>
> The same applies for referencing Entity beans from within other entities. Is
> there any standard here? What about using the Handle?
>
> The objective would be to come up with elegant solutions now that could be
> easily modified to comply with the EJB 2.0 spec or recommendations ;-).
>
> Thanks in advance,
> Lisa
>
> ===========================================================================
> 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".

===========================================================================
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".

Reply via email to