CMP finder method error

I'm now using Jbuilder7+weblogic7 to do some EJB develop.
Weblogic server is configured to run inside the Jbuilder IDE, and my CMP entity bean has been deployed successfully.
I new a "EJB test client" within Jbuilder to test my CMP bean, I could create entity bean via create method, but when I using finder method to find a bean, the client report that "java.sql.SQLException: No data found"!
My EJB-QL is:"SELECT OBJECT(o) FROM Account o WHERE o.ownername = ?1"
And below is the exception report:
javax.ejb.FinderException: Problem in findByOwnername while preparing or executing statement: 'weblogic.jdbc.rmi.SerialPreparedStatement@1d2384':
java.sql.SQLException: No data found
java.sql.SQLException: No data found
     at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6212)
     at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3266)
     at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5398)
     at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:326)
     at weblogic.jdbc.jts.ResultSet.getString(ResultSet.java:84)
     at weblogic.jdbc.rmi.internal.ResultSetImpl.getString(ResultSetImpl.java:178)
     at weblogic.jdbc.rmi.internal.ResultSetStraightReader.getString(ResultSetStraightReader.java:37)
     at weblogic.jdbc.rmi.SerialResultSet.getString(SerialResultSet.java:128)
     at cmptest.AccountBean_8259n1__WebLogic_CMP_RDBMS.__WL_loadGroup0FromRS(AccountBean_8259n1__WebLogic_CMP_RDBMS.java:945
Can anybody help me out? Thanks.

The Exception is pretty clear there are no Records found for the Owner Name u give. Try Creating the Suitable record from ur Entity Bean(create method of course) then check in the DB for the Record and then try to retrieve it....I don't think there should be any problem....
Cheers,
manja

Similar Messages

  • CMP Finder Method

    Could you supply a couple of examples of setting up a custom CMP Finder Method using both SQLJ and JDBC?
    In particular how is the SQL coded in the "SQL Query" textbox on the "Method" tab? How are the parameters and the result set referenced and returned? What is the return type?
    Simple Select / Where clause multirow and single row examples should suffice.
    I using JDeveloper 9.0.2.8.2.
    Thanks.

    You can create custom CMP Finder Methods which takes appropriate sql but not SQLJ and JDBC.
    i.e if you are adding a custom finder method in orion-ejb-jar.xml it takes only SQL not java code
    In JDeveloper select orion-ejb-jar.xml in the project and right-click on it and choose Settings option
    Select the Entity bean in the navigator and choose Finder methods
    Click on Add. The dialog box will allow to add a new finder method with SQL query
    Click on Help for specific information
    Couple of hints are
    Partial
    Whether or not the specified query is a partial one. A partial query is the 'where' clause or the 'order' (if it starts with order) clause of the SQL query.
    Queries are partial by default. If partial="false" is specified then the full query is to be entered as value for the query attribute and you need to make sure that the query produces a result-set containing all of the CMP fields. This is useful when doing advances queries involving table joins and similar.
    Query
    The query part of an SQL statement. This is the section following the WHERE keyword in the statement. Special tokens are $number which denotes an method argument number and $name which denotes a cmp-field name. For instance the query for "findByAge(int age)" would be (assuming the cmp-field is named 'age'): "$1 = $age".
    Return type can be collection if the query is returning more than one row of data or it could be the entity bean type itself (if it is only one row)
    raghu
    JDev Team

  • 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]

  • Writing CMP Finder SQL Syntax?

    What is the syntax for writing the finder SQL for CMP? From the CMP sample code for the OAS it looks like it might be &fieldname <op> $1 (for the first parameter?)?
    Joe McDaniel

    You can create custom CMP Finder Methods which takes appropriate sql but not SQLJ and JDBC.
    i.e if you are adding a custom finder method in orion-ejb-jar.xml it takes only SQL not java code
    In JDeveloper select orion-ejb-jar.xml in the project and right-click on it and choose Settings option
    Select the Entity bean in the navigator and choose Finder methods
    Click on Add. The dialog box will allow to add a new finder method with SQL query
    Click on Help for specific information
    Couple of hints are
    Partial
    Whether or not the specified query is a partial one. A partial query is the 'where' clause or the 'order' (if it starts with order) clause of the SQL query.
    Queries are partial by default. If partial="false" is specified then the full query is to be entered as value for the query attribute and you need to make sure that the query produces a result-set containing all of the CMP fields. This is useful when doing advances queries involving table joins and similar.
    Query
    The query part of an SQL statement. This is the section following the WHERE keyword in the statement. Special tokens are $number which denotes an method argument number and $name which denotes a cmp-field name. For instance the query for "findByAge(int age)" would be (assuming the cmp-field is named 'age'): "$1 = $age".
    Return type can be collection if the query is returning more than one row of data or it could be the entity bean type itself (if it is only one row)
    raghu
    JDev Team

  • 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.

  • CMP Custom Finder Method Problem

    Hi everybody,
    I have a problem about CMP Custom Finder Method.
    I made CMP Entity Bean and deployed.
    Then, I updated finder section in orion-ejb-jar.xml to add my custom finder query.
    Here is updating finder section in my orion-ejb-jar.xml.
    <finder-method query="(($schStartDate &lt;= TO_DATE($1,'MM-DD-YYYY a HH:MI') and $schEndDate &gt;= TO_DATE($1,'MM-DD-YYYY a HH:MI')) or ($schStartDate &lt;= TO_DATE($2,'MM-DD-YYYY a HH:MI') and $schEndDate &gt;= TO_DATE($2,'MM-DD-YYYY a HH:MI'))) and ($schRoom = $3)">
    <!-- Generated SQL: "......" -->
    <method>
    <ejb-name>RoomSchedule</ejb-name>
    <method-name>findBySchDateAndRoom</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    </finder-method>
    <resource-ref-mapping name="jdbc/OracleDS" />
    And, i restarted oc4j. so, oc4j redepoyed CMP bean.
    But, when my client program called CMP Bean, lookup() was ok, but calling findBySchDateAndRoom() was bad.
    I couldn't get any result collection.
    Here is my client code.
    Context ctx = new InitialContext();
    Object ref = ctx.lookup("RoomSchedule");
    roomScheduleHome = (RoomScheduleHome) PortableRemoteObject.narrow(ref, RoomScheduleHome.class);
    String startDT = new String("07-30-2002 am 10:30");
    String endDT = new String("07-30-2002 pm 05:20);
    String roomID = "TEST";
    Collection roomAllSch = roomScheduleHome.findBySchDateAndRoom(startDT, endDT, roomID1);
    Iterator roomSchItr = roomAllSch.iterator();
    int schQty = 0;
    while (roomSchItr.hasNext()) {
    roomSchedule = (RoomSchedule) roomSchItr.next();
    if(roomSchedule.getStatus().equals("A"))
    schQty++;
    After excuting above code, schQty was still zero!!
    Because Collection roomAllSch had not any items.
    But, table ROOMSCHEDULE had 30 records which were same query condition in my database.
    I traced SQL statement using P6Spy Class.
    Here is spy.log.
    1028006337814|10|0|statement|select * from RoomSchedule where ((RoomSchedule.schStartDate <= TO_DATE(?,'MM-DD-YYYY A.M. HH:MI') and RoomSchedule.schEndDate >= TO_DATE(?,'MM-DD-YYYY A.M. HH:MI')) or (RoomSchedule.schStartDate <= TO_DATE(?,'MM-DD-YYYY A.M. HH:MI') and RoomSchedule.schEndDate >= TO_DATE(?,'MM-DD-YYYY A.M. HH:MI'))) and (RoomSchedule.schRoom = ?)|select * from RoomSchedule where ((RoomSchedule.schStartDate <= TO_DATE('7-30-2002 ?@@| 01:00','MM-DD-YYYY A.M. HH:MI') and RoomSchedule.schEndDate >= TO_DATE('7-30-2002 ?@@| 01:00','MM-DD-YYYY A.M. HH:MI')) or (RoomSchedule.schStartDate <= TO_DATE('7-30-2002 ?@HD 12:00','MM-DD-YYYY A.M. HH:MI') and RoomSchedule.schEndDate >= TO_DATE('7-30-2002 ?@HD 12:00','MM-DD-YYYY A.M. HH:MI'))) and (RoomSchedule.schRoom = 'Earth')
    1028006337824|10|0|statement|select RoomSchedule.schTitle, RoomSchedule.schStartDate, RoomSchedule.schEndDate, RoomSchedule.schDayAll, RoomSchedule.status, RoomSchedule.schRoom, RoomSchedule.reqUser, RoomSchedule.apprUser, RoomSchedule.purpose, RoomSchedule.relatoinID, RoomSchedule.schDesc, RoomSchedule.reqDate, RoomSchedule.apprDate from RoomSchedule where (RoomSchedule.schID = ?)|select RoomSchedule.schTitle, RoomSchedule.schStartDate, RoomSchedule.schEndDate, RoomSchedule.schDayAll, RoomSchedule.status, RoomSchedule.schRoom, RoomSchedule.reqUser, RoomSchedule.apprUser, RoomSchedule.purpose, RoomSchedule.relatoinID, RoomSchedule.schDesc, RoomSchedule.reqDate, RoomSchedule.apprDate from RoomSchedule where (RoomSchedule.schID = 0)
    As you see it, two query statement were executed.
    First query statement was ok and got some result records.
    But, second query statement was bad so didn't get any result records.
    I didn't understand why second query statement was executed.
    When roomAllSch.iterator() was being excuted in my client program, second query statment was executed.
    I couldn't believe....
    What's wrong? Please help me....
    OC4J : Version 9 Release 2
    Database : Oracle 8i
    OS : Windows 2000 Professional

    I created CMP of EJB 1.1, I wanted to add a finder
    there, but it didn't work.
    the error message is:
    "AccountEJB_vkbo0d_HomeImpl.java":
    AccountEJB_vkbo0d_HomeImpl should be declared
    abstract; it does not define findBySalary(float) in
    AccountEJB_vkbo0d_HomeImpl at line 11, column 1I think I don't remember CMPs having finder methods anything other than abstract. The code goes in the deployment descriptor. I hope you atleast got that right.
    Richard.

  • 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

  • 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

  • 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

  • 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

  • Error "Unable to find method:key" on UM configuration iView

    When i try to click on the UM configuration in System Administration --> System configuration i am getting the Error Unable to find method:key  Does any one came across the same Issue. Please help ?

    Server restart should help. See note 792929.

  • Error in finder method wrapper resulting in a connection leak

    we ar using OC4J 1.0.2.2.1 and dicowered some problems with connection leaking.
    The same was reproducable on 9.0.2.1 and 9.0.3 (the "J2EE 1.3 certified" version).
    Using CMP/CMT for Entity EJB.
    If we define the transaction attribute for a finder method returning single object as NotSupported
    and ObjectNotFound exception is thrown as a result of call to the finder method,
    connection is not closed.
    With emulated datasource this results in a connection pool overflow, with XA datasource
    the console gets conenction not closed exceptions but at least connections are closed (seriously influencin performance while waiuting for connection timeout).
    the same code executes with no problem on JBoss 2.4.x and 3.0 and on iPlanet.
    any comments on this - is this a bug or feature ?

    Please log a TAR with your support repesentative so that we can drill down on this issue. As described, this does not sound like the correct behavior but until the details are examined it is hard to tell.
    Thanks -- Jeff

  • Does CMP bean finder method supports "LIKE" sql?

    I put something like this in the orion-ejb-jar.xml file:
    <finder-method partial="false" query="select * from EMP where $ename like $1 AND $job like $2">
    </finder-method>
    If I put in exact value like 'ADAMS' or 'CLERK', it works fine. But if I put in 'A%' or 'CL%', it does not work. I know the record is there and the same sql does return a row in sql-plus.
    Appreciate any help.
    Adam

    I put something like this in the orion-ejb-jar.xml file:
    <finder-method partial="false" query="select * from EMP where $ename like $1 AND $job like $2">
    </finder-method>
    If I put in exact value like 'ADAMS' or 'CLERK', it works fine. But if I put in 'A%' or 'CL%', it does not work. I know the record is there and the same sql does return a row in sql-plus.
    Appreciate any help.
    Adam gday Adam -
    I don't think there is anything in the persistence manager that will prevent this from working as you want.
    Can I ask what version of OC4J you are using?
    I'm not sure from your email if you are you specifying the fields in the finder method by surrounding them with SQL style quotes as in 'A%'? You shouldn't need to do that if you are.
    I just tested it out with a simple client and entity bean based on the employee table, which I created in about 30 seconds with the new JDeveloper CMP Entity Bean Wizard, using the create from existing table option.
    I added a finder method that looks like the following:
    Collection findByEnameAndJob(String ename, String job) throws RemoteException, FinderException;
    And then changed the SQL in the finder dialog (or orion-ejb-jar.xml) for the finder to be
    <finder-method partial="False" query="select * from emp where $ename like $1 and $job like $2">
    <method>
    <ejb-name>Emp</ejb-name>
    <method-name>findByEnameAndJob</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    </finder-method>
    The client code then looked for employees with a name starting with the letter A and whose job started with the letters CL as follows:
    Collection coll = empHome.findByEnameAndJob("A%","CL%");
    System.out.println("*** There were : " + coll.size() + " records returned ***");
    Iterator iter = coll.iterator();
    while (iter.hasNext())
    emp = (Emp)iter.next();
    System.out.println("empno = " + emp.getEmpno());
    System.out.println("ename = " + emp.getEname());
    When the client was run, this was the resulting output:
    *** There were : 1 records returned ***
    empno = 7876
    ename = ADAMS
    job = CLERK
    mgr = 7788
    hiredate = 1987-05-23 00:00:00.0
    sal = 1100
    comm = 0
    deptno = 20
    If you want to find all the entries that have a job that starts with CL you can even use the same finder method like:
    Collection coll = empHome.findByEnameAndJob("%","CL%");
    This results in the output
    *** There were : 4 records returned ***
    empno = 7369
    ename = SMITH
    job = CLERK
    mgr = 7902
    hiredate = 1980-12-17 00:00:00.0
    sal = 800
    comm = 0
    deptno = 20
    empno = 7876
    ename = ADAMS
    job = CLERK
    mgr = 7788
    hiredate = 1987-05-23 00:00:00.0
    sal = 1100
    comm = 0
    deptno = 20
    empno = 7900
    ename = JAMES
    job = CLERK
    mgr = 7698
    hiredate = 1981-12-03 00:00:00.0
    sal = 950
    comm = 0
    deptno = 30
    empno = 7934
    ename = MILLER
    job = CLERK
    mgr = 7782
    hiredate = 1982-01-23 00:00:00.0
    sal = 1300
    comm = 0
    deptno = 10
    I can send you the packaged EAR file if you want to try this simple example for yourself - or you I would even encourage you to grab JDeveloper 9i and see how it easy it makes it to build and test the example I was just working with.
    cheers!
    -steve

  • 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

  • CMP and Finder methods

    I've got a table:
    id number primary key,
    name varchar2(50),
    price number
    How can i make finderXXX for this sql query:
    select * from table where name like 'beer' and price > 10;
    Thank's

    gday Max -
    For this, you'll need to make some a slight modification to the generated finder methods.
    Say you create an entity called Drinks which has the same structure as the table you provide as an example (and can I just say, what a great example you chose ;)
    It should go something like this - note, I've not tried this but this is what you need to look at doing:
    In the Home interface (DrinksHome) create a findermethod that looks like:
    public Collection findByName(String name, Double Price) throws RemoteException, FinderException;
    * note we make the return type a collection since it's possible that you may get more than one entity returned.
    Go ahead and deploy your EJB.
    When you deploy your EJB, OC4J will generate a finder method for this method for you.
    Now what you need to do is to modify the generated XML deployment descriptor to tune the query if you will.
    OC4J generates the deployment descriptor info it needs for an application in $OC4J/application-deployments.
    Go to to $OC4J/application-deployments/<app-name>/<ejb-name> where app-name and ejb-name are specific your deployed EJB.
    Open the orion-ejb-jar.xml file. This is the file OC4J uses to describe the deployed beans.
    Search through the file until you find the <finder-method> tag.
    Amend the query attribute of the finder-method tag to reflect the where clause of the query you want to execute:
    query="$name = $1 AND $price > $2"
    Now go to the generated SQL string and add the corresponding SQL where condition, using a ? in place of the actual value of the query string above
    It would become something like ...
    < !-- Generated SQL: "select drinks.id, drinks.name, drinks.price from drinks where drinks.name = ? AND drinks.price > ?" -->
    Note that in this query, the where clause matches the query you specified, but you omit the actual values.
    Check the method-params defined for the find below and ensure that the order of them lines up with the values you've specified in the finder query.
    Stop OC4J and restart it and the new finderMethod should come into effect.
    Give that a try and see how you go.
    cheers!
    -steve-
    null

Maybe you are looking for