Hello all,

Please consider the following pseudo-code as a possible solution for
polymorphic finders (this example assumes the existence of an entity bean
X, that is extended by entity bean Y)

public class EntityXFinderBean // a stateless session bean
{
     public EntityX[] findBySomeValue(SomeValue aValue)
     {
          SELECT pk FROM EntityXTable where someField = :aValue

          while (ResultSet has more records)
          {
               Get Primary Key from ResultSet.
               Get most derived type of instance from Primary Key // (ie.
the Primary Key encodes the name of the instance's most
                    derived type, which could be X or Y depending on what
we inserted)
               Lookup the name of the home interface for the derived type.
               Call findByPrimaryKey on the home interface, passing in the
Primary Key.
                    // This step may require either the use of
Method.invoke() to work correctly,
               Add the returned remote reference to the array of results.
          }
     }
}

So,

1. This solution results in extra classes, beans that you wouldn't
otherwise have (of course, you could have one FinderBean for a range of
classes).
2. I am not sure whether this would necessarily perform significantly
slower than a regular ejbFindByXxxx() call. When does an app server call
ejbLoad to bring an entity bean into existence (assuming it isn't already
in memory) - right after ejbFindByPrimaryKey is called - or once a client
makes a method call on the remote reference.

We're currently priding ourselves on what looks like a reasonable solution
to the problem, but I'm keen to have someone shoot this one down if there
are glaring flaws we're overlooking (other than, the EJB spec should
specify a decent solution for inheritance!)

Regards,
James W.

--------------------------------------------------------------------------
Visit us at Cards Australia 2000 on Stand 31A.  Cards Australia will be
held at the Melbourne Convention Centre from July 4-6 2000.
--------------------------------------------------------------------------
This e-mail is from Cards Etc Pty Ltd (ACN: 069 533 302). It may contain
privileged and confidential information. It is intended for the named
recipient(s) only. If you are not an intended recipient, please notify us
immediately by reply e-mail or by phone on +61 2 9212 7773 & delete this
e-mail from your system.
--------------------------------------------------------------------------

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