findAll method in weblogic5.1 wlql

Discussions

EJB programming & troubleshooting: findAll method in weblogic5.1 wlql

  1. findAll method in weblogic5.1 wlql (2 messages)

    I have tried to declare a findAll method with weblogic 5.1 and I can't
    get it right (CMP).

    In the online-documentation I have found the following:

    "...
         The following example finds all the EJBs in a table. It uses the
    sample finder method signature:

            public Enumeration findAllAccounts()

                  throws FinderException, RemoteException

           The sample <finder> stanza uses an empty WLQL string:

            <finder>

                  <method-name>findAllAccounts</method-name>

                  <finder-query></finder-query>

            </finder>
    ..."

    but if I do such a method I get following exception:

    "......
    javax.ejb.FinderException: Exception preparing or executing statement:
    'select id, balance from tblAccount where'
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL
    Server]Line 1: In
    correct syntax near 'antalRum'.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:4089)

            at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
            at sun.jdbc.odbc.JdbcOdbc.SQLPrepare(JdbcOdbc.java:2714)
            at
    sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(JdbcOdbcConnection.
    java:241)
            at
    weblogic.jdbcbase.jts.Connection.prepareStatement(Connection.java:138
    )
    ..."

    It looks like weblogic generates a SQL-statement 'select id, balance
    from tblAccount where' instead of 'select id, balance from
    tblAccount'

    Can somebody explain this

    Regards

    Shakti Mishra





  2. You may be required to put a where clause inside your finder-query tag. I know this option is not very elegant, but if you never use zero for the id you could do something like this:

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

    When you call the findby, pass in a 0 value.

    Word of caution, generally you don't want to retrieve all the records in a distributed system unless it is a very small set of data. If it is a large amount of data, you will bring your system to its knees.

    Atleast this should work,

    Kent
  3. The same problem i was getting when i was trying to search all records. U might be using database as sqlServer. What i did was u just check your primarky key field with not null and u will get the solution what u want. Because ur primary key always have some value of u will all the data.