Dan,

I can think of initially 2 ways (apart from session beans) which you can use
to solve this problem. First off you could use a finder method which
included all the parameters and used OR and IS NULL in the where clause to
support smaller criteria sets. The finder method would look something like

<finder>
<method-signature>findByUsingSomeParameters(String p1, String p2, String p3,
String....)</method-signature>
<where-clause>
        (:p1 IS NULL OR :p1 = col1) AND
        (:p2 IS NULL OR :p2 = col2) AND
        (:p3 IS NULL OR :p3 = col3) AND .......
</where-clause>
<load-state>True</load-state>
</finder>

or if the multiple 'IS NULL' and 'OR' is not to your liken then you could
implement the first finder (hybrid) in your bean code which would load the
list of string/int/long pks from the database and create an array which is
then passed to a cmp finder on the home i.e. findByPrimaryKeys (int[] pks).
The container would then generate a sql which used a IN clause like

where pkcol in (a0,a1,a2,a3.....)

where aN is the element at index N in the array. The first finder would be
implemented by your bean using dynamic sql statement generation depending on
the parameters passed. Of course this will require your entity bean to have
knowledge of its persistence mapping but at least its centralized. If in the
future you container provides the dyn sql support you can move to this
without requiring a rewrite of potentially multiple session beans i.e.
clients would be unaware of the change of implementation. The reason for the
second call to the home is to load the state of multiple entity beans in one
sql instead of M (no. of entity beans returned) calls - performance.

The Inprise Application Server 4.1 (IAS) ejb container's built in cmp engine
supports the above. You should check-out whether the above is supported by
your containers cmp engine. if not then its back to the session beans + sql
+ jdbc calls.

regard

William Louth
Inprise
www.inprise.com/appserver


-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Dan Hinojosa
Sent: Saturday, September 02, 2000 9:04 PM
To: [EMAIL PROTECTED]
Subject: Flexible Find Methods


Sometime I have more than one condition to look for.  For example,
"Select * from table1 where (a = b) and (b = c) and (d = e).  Sometimes
I will have one condition and at other times I will have multiple
conditions. finder Methods on the home interface using CMP doesn't allow
the flexibity since the container manages the SQL internally.  Do I have
no other choice than to go BMP, or is there another light at the end of
the tunnel?

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