Hi Stefan,
at first: the finder methods are defined in the home-interfaces
(see section 8.3.2 of the EJB-Spec.1.1.)

for example:
        public Account findByPrimaryKey(String user_id)
        throws FinderException, RemoteException;
        public Collection findByLastName(String name)
        throws FinderException, RemoteException;
        public Collection findInRange(double low, double high)
        throws FinderException, RemoteException;

The Entity-EJB has to define one ejbFind[...]-method for each of this methods.
That means, that this methods contain calls to special methods with
SQL-Queries.

example:

      public String ejbFindByPrimaryKey(String primaryKey)
      throws FinderException
    {
      System.out.println("ejbFindByPrimaryKey method");
      try {
         if (selectByPrimaryKey(primaryKey)) {
            return primaryKey;
         }
         else {
            throw new ObjectNotFoundException
               ("Row for id " + primaryKey + " not found.");
         }
       } catch (Exception ex) {
           throw new EJBException("ejbFindByPrimaryKey: " +
              ex.getMessage());
       }
    }

last but not least:

        private boolean selectByPrimaryKey(String primaryKey) throws
java.sql.SQLException
      {
         System.out.println(" selectByPrimaryKey method");
         String selectStatement = "SELECT ID FROM TABLE WHERE USER_ID = ? ";
      PreparedStatement prepStmt =
(PreparedStatement)con.prepareStatement(selectStatement);
          prepStmt.setString(1, primaryKey);
          prepStmt.executeQuery();
          ResultSet rs = (ResultSet)prepStmt.executeQuery();
          boolean result = rs.next();
          prepStmt.close();
          return result;
    }

Hope, this helps you to solve your problems.
regards
Nail
   - Dep.of CS -
  Univ. Hamburg

*******************************************************************************************

Stefan Hanenberg wrote:

> Hi,
>
> I have a question: I have an EntityBean without a primary key-class. How
> can I use it within the j2eesdk and cloudscape? The main problem is:
> What are the SQL-statements for ejbRemove() and findByPrimaryKey()?
>
> Regards,
> Stefan
>
> ===========================================================================
> 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