You need EJB-QL.  With EJB-QL you can specify the SQL like queires which
gives all the objects that match the query.

Example:
in your home have a method like this.
public java util.Collection findMatchPassword(String passwd) throws
FinderException, RemoteException

In your deployment descriptor write query like the following

SELECT OBJECT(o) FROM Users WHERE password =?

Here the Users is the abstract-schma-name for the entity bean and password
is cmp-field.  You can write much more complex queries using EJB-QL with cmp
relationships.


----- Original Message -----
From: "Kevin Duffey" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Thursday, August 16, 2001 2:20 AM
Subject: Finding an entity in a Collection returned by findAll()


> Ok..still new to this EJB thing. Got my entity bean stored in the hSQL
> table, I am able to iterate over the Collection returned by the findAll()
> method. Now the question is, how do I find my one object? More
specifically,
> I created a simple entity that has a name (primary key), login, and
> password. I added a couple of items to the table. Now, like I said I can
see
> all the items added..so they are being stored. Now I want to search for
the
> login and password that someone types in. I see the findByPrimaryKey()
> method, which would find one item via the primary key of name. But how do
I
> search by the login and password for one item to see if it exists, or by
> those fields to get say..a series of items with the same criteria (for
> example, all rows that contain the same login name..assuming its not a not
> null column which if I am correct, CMP only makes NOT NULL out of primary
> keys).
>
> Thanks.
>
>

Reply via email to