How to implement find methods in CMP?

As OC4J does not support EJB-QL, we need to implement the find methods by ourselves. But how? Here is my thought.
1) Still declare the find methods in EJB home, such as
public Collection findBySponsor(String sponsorGuid);
2) Do not add query part to ejb-jar.xml file;
3) In the bean class, implement the find method using JDBC code.
Does CMP allows explicit-implementation of finder methds?
Does CMP allows explicit-call to JDBC code?
Thanks,

Henry -- Why go to that trouble? For the near term I would suggest that you just modify the generated
orion-ejb-jar.xml descriptors which will include tags to allow you to either 1) enter a partial criteria or
2) enter a complete SQL statement. This is much less work and when EJB-QL is available with the product,
then you have to only add the EJB-QL to the ejb-jar.xml.
Thanks -- Jeff

Similar Messages

  • Finder methods for CMP beans

    We do not implement finder method in Bean class for CMP. As such, where do we implement finder methods such as findInRange() method? How does the container implement my custom "find" methods.
    Thanks

    Using CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
    See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
    --ken
    Kenneth Saks
    J2EE SDK Team
    SUN Microsystems

  • How implement finder method with bean inheritance?

    I have a ProductBean which is the super class of BookBean, ClothesBean and I want to create a find method like:
    public ProductRemote findAllInCategory(Integer categoryID) throws FinderException, RemoteException;Since each bean is going to have its own table, what's the best way to do this? Is this even possible with CMP find methods?

    I dont think inheritance is going to work here, cos when u write the ejb-ql for the method, there you have to provide the table names and u said each bean has different tables.

  • Binary Data Type in finder methods for CMP beans

    How to write an equivalent ejb-ql query in ejb-jar.xml for a finder method accepting
    a byte array as a parameter. The finder method is for a cmp-field mapped to a
    database field with binary data type

    Using CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
    See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
    --ken
    Kenneth Saks
    J2EE SDK Team
    SUN Microsystems

  • Using wildcards in custom find methods with CMP beans

    Hi,
    I'd like to create a custom find method called findByName which accepts a string. I'd typically want to use the string in a '%<name>%' scenario, where the user needn't type in the whole name. Does anybody know what the partial query should look like? I'm not sure how to concatenate the '%' symbol to the string taken in.
    Thanks in advance
    Gillian

    Gillian-
    Bind variables are of the form $1, $2, etc., so try using a query stmt like this:
    select * from YOURTABLE where name like '%$1%'
    Regards,
    -Jon

  • How to implement Find & Replace

    Hello,
    I have a mini editor based on a JEditorPane. How can I implement find & replace function visually, like any editor does?

    Hi there,
    the latest stage of SimplyHTML implements find & replace. You can find all (app, docs, sources) at http://www.lightdev.com/template.php4?id=3
    A screen shot for the find & replace dialog it implements:
    http://www.lightdev.com/template.php4?id=34
    Online documentation for find and replace
    http://www.lightdev.com/doc/shtm/rel/help/topic16/topic173.htm
    Manual as PDF file (see chapter 'Inside SimplyHTML' -> 'Stage 11: Find & Replace')
    http://www.lightdev.com/doc/shtm/rel/Help.pdf
    API docs (including find & replace functions)
    http://www.lightdev.com/doc/shtm/rel/api/index.html
    Have fun
    Ulrich

  • How To Implement Find Option

    Hello frnds,
    I am working on a project whose aim is to make an editor completely in java. But i m unable to implement feature like Find.
    Please suggest me how to implement this.
    Thnx

    if your editor is a jtextarea, i would suggest something like that:
    String textTyped = textarea.getText();
    String lookForText = new JOptionPane.showInputDialog("text you look for?");
    int indexOfTheText = textTyped.indexOf(lookForText);
    textArea.moveCaretPosition(indexOfTheText);maybe the instruction to focus on the caret after the caret move is missing here
    just try :)

  • How to implement custom methods on form submit

    I'm a newbie to ADF environment, coming from pl/sql world. I have already tried default drag and drop functionality for forms. But, with new requirements, I need to write some custom code to create and update form. I read about managed beans, but didn't quite understand it. Any pointers to examples are appreciated.
    Regards,
    Surya
    Edited by: sgodavar on Sep 29, 2010 1:13 PM

    Suganth,
    Sometimes, the default form to create and edit built (drag and drop) on top of BCs may not be enough to code all the business logic. In that case, I'm looking for the basic steps involved to implement such custom logic. For example, I may need to call a managed bean or some stored procedure from ADF faces. Since, I'm totally new to ADF, I don't know how to go about it and right way to do it in ADF environment. Any pointers to such examples are appreciated.
    Regards,
    Surya

  • How to implement DAO pattern in CMP

    How do I use the DAO pattern when going for container managed persistence, because all the database access is defined by the CMP.
    How to go about it ?

    Hi,
    The DAO pattern http://java.sun.com/blueprints/patterns/DAO.html
    is used with Bean Managed Persitence(BMP). For CMP you should not write the SQL in the EJB code, but instead let the container generate the SQL and handle all the data access.
    Another pattern that might help when modelling your EJBs is the Composite Entity pattern at
    http://java.sun.com/blueprints/patterns/CompositeEntity.html
    Also, the new J2EE BluePrints book has some tips and strategies in the EJB tier chapter at
    http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/index.html
    hope that helps,
    Sean

  • How to implement sql query in cmp bean?

    let's say that i want to join two tables and use grouping, counting and sorting expresion. it is no problem with sql query but what about cmp bean?
    of course i can make one bmp bean or session bean and run directly sql expresion, but then what is the point of using cmp beans?
    thanks
    winnicki

    If yout need post-query for filling descriptive colums (eg. department name in emploees) you should build a view object which includes the descriptive colums by joining the relevent tables

  • How to make find methods return a subset of the result?

    Take the multipage apps for instance,
    it is a common idea to return only a subset(No. 10~No. 30) of the full-list especially when there are millions item in the full-list.
    Please help me:)

    Maybe you're looking for something like a "Value List Handler"
    http://developer.java.sun.com/developer/restricted/patterns/ValueListHandler.html

  • Finder Methods other than by Primary key

    How should the Finder methods other than by Primary
    key in Container MB be implemented? In Bean class?
    I did some search in archives to no avail.
    Thanks!!
    Sriram

    I think it might be different on different app servers, at least until EJB 2.0 is implemented everywhere. I found a bit of info on the matter:
    http://www.jboss.org/documentation/HTML/ch06s07.html

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • EJB CMP finder methods

    The Oracle documents suggests that the following definition in the EJBHome is enough to create a finder method
    public Enumeration findByWhere(String where) throws RemoteException, FinderException;
    I get a java.lang.AbstractMethodError on the client when I try to call this - suggesting the the container is not implementing the method for me.
    I see no place in the oracle descriptor to define these finder methods.
    What is the deal with these ? How does one use CMP and Finder methods other than the standard "findByPrimaryKey(....)
    thanks
    null

    Hello,
    Let say you don't want to uyse the defualt finder methods, then you can write your own like:
    (in client servlet/JSP file etc..)
    emps = home.findByLast_name(request.getParameter("searchText")); //find by last name
    where:
    step 1) go to EJB class editor (under your main EJB directory)
    step 2) click on finder tab and click add, to add new finder methods
    step 3) (you can click help now to get more info on this..anyways) findBy<CMB field>
    would automatically check the "Managed by OC4j" check box, this means that you have matched a signature tag for finders (kind of like setXX and getXX if you are doing JavaBean...automatically done for you)
    step 4) else you can make one that is not up like findWildCard(String wildCard):
    i)by specifying the Method name to be: findWildCard
    ii)parameter (String type: wildCard)
    step 5) rebuild the EJB directory after you add this method
    step 6) use it in any of you client servlet/JSP as you would with the defualt findAll() methods etc..
    cheers,
    -Long
    [email protected]

  • How to limit a number of rows to be returned in finder method

    are there any way we can specify the # of rows to be returned in a finder method for an CMP? how should we specify that within the xml configuration files?

    Hi
    Sorry to say that u can't do it in the current versions. Only thing u can do is to get all of them and filter them out at the client or servlet layer.
    For exapmle if u get the Enumeration (say 25 objects), and u want to show 10 at a time. Keep a variable that keep track of the page number (eg whether it's the first 10 set of records nor next). Keep the Enumeraton that u got in the session (so that u don't get it everytime). When next is pressed, depending on the value of the varaible storing page number skip those number of records in the Enumeratin (eg if u are going to the second page, the number of records to skip will be 1*10 = 10, and get records form 11 to 20 and so on........
    What do u say.......this is how I did it in an appilaction.........
    Chandan.

Maybe you are looking for

  • From MSS Requisition request is not coming in Recruter UWL.

    hello everyone, we are creating Requisition request in MSS. But Request is not reaching Recruter UWL. We tried to find so many ways to solve this problem. We got to know that there is problem in workflow. we are getting follwoing error. Object CL_HRA

  • Issue with loop in table control

    Hello experts, I have 20 entries in my table controlĀ  but the loop is going through only for 10 entries..please help me? Thanks

  • IE 10 vs Adobe reader XI and Adobe flash player 11 keeps asking to update flash player

    Today, I got fed up with chrome and uninstalled it. I then installed IE 10. I also installed adobe reader XI (11.0.02) and adober flash player 11. Both installed successfully! However, when trying to view short videos I keep getting the message that

  • PDFs are not generated from Burst

    Hi all I am getting this error when i schedule my report to run: Document generation failed [INSTANCE_ID=V110APLFFC006.1305547398367] [OUTPUT_ID=1035][ReportProcessor]Error rendering documentoracle.xdo.servlet.scheduler.ProcessingException: [ReportPr

  • Workflow not getting triggered from webdynpro event

    Hello gurus, I have a requirement in which if an employee changes his own information on the ESS portal, then an approval should be done by HR. For this i created a custom webdynpro application in which i fetch the employee data and check it with old