For EJBs that need to be looked up a lot within the server code, I code in 
a static lookup() function in the implementation class. E.g. in 
ContributionLogEntryBean:

/**Static convenience method for looking up ContributionLogEntry objects.*/
public static ContributionLogEntry lookup(int iKey) throws RemoteException
{
      try
      {
        Context ctx = new InitialContext();
        String sHomeName = 
EJBHelpers.getHomeInterfaceClassName(ContributionLogEntryHome.class);
        ContributionLogEntryHome home = 
(ContributionLogEntryHome)ctx.lookup(sHomeName);
        return home.findByPrimaryKey(new ContributionLogEntryPK(iKey));
      }
      catch (FinderException e) {throw new RemoteException(null,e);}
      catch (NamingException e) {throw new RemoteException(null,e);}
}

Then when the implementation of another bean needs to grab a 
ContributionLogEntry it can just do ContributionLogEntryBean.lookup(). Note 
that the use of a static helper here is perfectly valid - it's just 
equivalent to inserting this code in the calling function.

Joe


-----Original Message-----
From:   Joel Shellman [SMTP:[EMAIL PROTECTED]]
Sent:   Tuesday, April 04, 2000 9:50 PM
To:     [EMAIL PROTECTED]
Subject:        Entity bean to Entity bean call

In the ejbCreate method of my entity bean (MemberBean) it needs to:
1) lookup another entity bean (another MemberBean) via a finder method
(findByLogin)
2) just the primary key back (can I do that? I don't need the whole
object)

Is there a standard way of doing that or do I need to call out to
getting initialcontext, lookup, etc.?

Thank you,

Joel Shellman
http://www.ants.com/
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
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 "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to