Say you wanted to show the large accounts in a client side Table GUI
component.

 The original take on this was that querying for the Primary Keys, returning
the primary keys, and then
getting each primary key in turn from the AccountHome was horrendously
expensive.

Rather we saw that one call to a session bean which created helper
objects(basically a lightweight table row version of the Account bean) from
one SQL select statement which return them in a collection of some sort was
much more realistic.

The second take was that it was a session bean that talks back and forth to
the entity bean, so bandwidth wasn't a terrible problem.

The third take was that these entity beans are being created, when 99% of
them aren't going to be accessed except for the summary information.  And it
still didn't seem realistic to do a 100 select statements (to load each
Account) versus just one (to just create the summary objects).

To be more clear, use this code instead in a session bean..

public Vector getLargeAccounts()
   throws RemoteException
{
  ResultSet rs=m_conn.prepareStatement("SELECT name, accountid, deposit FROM
accounts where deposit > 10000");

  Vector v=new Vector();

  while(rs.next())
      v.addElement(new AccountSummary(rs.getString(1), rs.getInt(2),
rs.getDouble(3)));

  return v;
}

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