How to declare/implement user defined Finder Methods

Discussions

EJB programming & troubleshooting: How to declare/implement user defined Finder Methods

  1. Hi Friends,

          Usually Entity bean's ejbFindByPrimaryKey(type xxx)is used to find existing entity bean in storage depends on the Primary Key. But I have the requirement to get the existing beans depends on the mulitple conditions.
         
        Suppose let us take a table
        --------------------------
        EMPLOYEE (empid-Primary key, empname, salary,dept).
        
        Now I want to find out the employe whose salary is greater than 20000 and dept is "Administration".

       Then How can I frame the ejbFind method.. does it necessary to implement this method in bean implementation class?....How can I declare this method in Home Interface?...

        Please suggest the solution regarding this....
        Expecting earliest valuable replies from ur side...
    By
    Satya
  2. Hi Satya,
       If that is a CMP, u need not have to write the implementation for this finder method in the bean class. u just have to define this finder method in the Home interface.

        Then u've to make a corresponding entry in the weblogic-rdbms-cmp-jar.xml file. u've to write a small description about this finder query. (please consult the appropriate documentation for further details).

        Your <finder-query> will look like
          
        [!CDATA[(&(> salary 20000)(= dept "administration"))]]

    Pls. update me when u've solved this.

    thanks...hasan
    (ahamed at aztec dot soft dot net)
  3. Hi Ahmed

    Thank u for ur suggestion..Actually I am using Websphere.
    For generating deployed jar I am using Visual Age for Java.
    In this case no need of writing deployement descriptors.
    I dont think this VA java providing user defiend descriptors. Please help me in this regards how to solve my problem of having more than one find methods in ejb(CMP)(1.0).

    Thanks,
    Satya.
  4. Hi:
       I've used VA Java for several projects . As I know , VA Java have the class of "FindHelper" which is the right place for you to write down your own find method . You will achieve your aim simply by writing a statement similar to SQL such as " salary >= 20000 " . Go and try it . Good Luck!
       If you have any problem , contact me : berethu at 263 dot net