Hi Dries,

We are implementing the concept of LIKE in our application.  We have some 20
CMPs and we use this for almost all of them.

Solution:
We append the '%' to the parameter before we actually call the finder method.
for example : If the field name is �paramA�.  When the user specifies the
search in this �paramA�, we append '%� to the paramA value and pass it to
finder method.  So the user need not append any % to his search.
The below line is a weblogic implementation for CMP

<finder-query><![CDATA[(&(= systemId $0))]]></finder-query>

Now this 0 will be 'praramA%'.  Did I give you the answer.  :)

One more input : Case Sensitive search.
To avoid case sensitive search, we preferred using UPPER on both sides of the
operator (LIKE).  But we could make only the parameter as upper, while the
actual column could not be done.  In the above query, we could not put
'systemId' as upper.  So we have a problem.

For this, we actually opened the '****_RDBMS.java' while compiling the bean and
edited the file to make the column as upper.  (something like UPPER(systemId)).
 Again we compiled the file and put in the jar.  The above java file is
generated when the ejbc command or weblogic.ejbc command is run with the
keepgenerated option.

Hope I did not confuse you.  Please revert back if you an questions.

Regards,
Prasad.



-----Original Message-----
From: demoord [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 20, 2002 7:43 PM
To: EJB-INTEREST
Cc: demoord
Subject: EJB QL query with LIKE operator

Hello,

I having the following problem.
A table named test with 3 colums A,B and C (VARCHAR type)
I write a CMP entity bean. Because I want the user to search throught this data
I provide a findTest(paramA, paramB, paramC)
I don't know which fields the user will enter and I don't want to check on it
because you have several possibilties.
So the query I define is like:
SELECT OBJECT(b) FROM test AS b WHERE (b.ColumnA LIKE '?1%') AND (b.ColumnB
LIKE '?3%') AND (b.ColumnC LIKE '?3%')

If I generate SQL statement with the deploytool of Suns reference
implementation it doesn't show out any  error.
When I run the client application and I do a search I always get 0 results back.
Can somebody tell me if the EJB QL is correct and if not give a solution?


Thanks a lot

Dries

===========================================================================
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".
 << File: EJB QL query with LIKE operator.TXT >>

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