Actually it makes more sense to place the % in the finder method as it
abstracts the SQL from the underlying code. A developer working with entity
beans should never need to use any SQL (even if it only is one character).

The reason the attempted finder method isn't working is to do with how JDBC
prepared statements work.

To fix the problem, in your <finder-method> tag in the deployment
descriptor, replace:

    like '%$1%'

... with ...

    like '%' + $1 + '%'

-Joe Walnes

----- Original Message -----
From: "DeVincentiis Giustino" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Thursday, October 19, 2000 11:59 AM
Subject: R: customize finder method


Hi Leung,
You should'nt use the '%' symbols in the finder definition, instead you
should attach them to the parameter you pass to the finder method.
i.e.
finder definition:
<finder-method query="select catname,description from cat_ejb_Category
where $description like $1">
finder calling:
findBy...("%" + description + "%");

Hope this help
Giustino De Vincentiis


-----Messaggio originale-----
Da: Yeung Man Leung [mailto:[EMAIL PROTECTED]]
Inviato: giovedì 19 ottobre 2000 9.57
A: Orion-Interest
Oggetto: customize finder method


Hi all,
    I have try to customize the a findBy method in one of my Bean in the
following.
                        <finder-method query="select catname,description
from cat_ejb_Category where $description like '%$1%'" partial="false">
                                <!-- Generated SQL: "select
catname,description from cat_ejb_Category where
cat_ejb_Category.description like '%?%'" -->
                                <method>

<ejb-name>cat.ejb.Category</ejb-name>

<method-name>findByDesc</method-name>
                                        <method-params>

<method-param>java.lang.String</method-param>
                                        </method-params>
                                </method>
                        </finder-method>

   However when I try to execute the findBy method,
    I got the following exception:
    com.evermind.server.rmi.OrionRemoteException: Database error:
ORA-01006: bind variable does not exist

    Did anyone know what went wrong in my sql, thx

Leung




Reply via email to