[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> once said:
> [ I'm trying to use inheritance with EJB entity beans ... ]
>
> Have I missed some subtlety of the EJB spec or XDoclet?

I think you missed the part of the EJB spec that says, "Do not attempt
to use standard object-oriented concepts like inheritance and
polymorphism with entity beans unless you are criminally insane." For
lack of evidence, let us assume insanity and go from there.

As you've discovered, home interfaces follow the inheritance hierarchy,
and this causes problems with the finders (and ejbCreate too). Off the
top of my head, the easiest way to solve the finder problem would be to
declare the findById() in the superclass, *rename* the finder for the
two subclasses (to avoid overloading the return type), and then use
merge points for the subclasses to override the superclass's finder. The
merge file should have findById() as per the superclass, but delegate to
the subclass finder methods.

  ReferenceDataHome

    // from @ejb.finder
    ReferenceData findById ( String id ) { ... }

  AvailabilityHome

    // from @ejb.finder
    Availability findByAvailId ( String id ) { ... }

    // from merge file
    ReferenceData findById ( String id ) { return findByAvailId(id); }

This assumes there *is* a merge point for custom finders and you can
solve the problem created by overloaded ejbCreate methods. Of course,
you probably don't declare a create method for ReferenceData (as I do
not for BaseEJB), so you should be fine there.

My angle of attack so far has been to handle these issues in the session
bean layer. No one accesses entity beans directly. True, the session
bean then has to deal with the inheritance issue (if/then logic to call
appropriate finders and create methods), but I find it easier to do
there and it's consistent. Plus you'll find plenty of patterns to help
you out. Clients are then left with a cleaner API. Granted, I've limited
my inheritance due to the problems you're having. I have a single
BaseEJB that all others extend, and it goes no further. :(

I hope something up there helped you out. I'm sure others on this list
will have more experience with mixing EJBs and inheritance.

David Harkness
Sr. Software Engineer
Sony Pictures Digital Networks
(310) 482-4756


-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to