Error using LIKE in EJB QL

Discussions

EJB programming & troubleshooting: Error using LIKE in EJB QL

  1. Error using LIKE in EJB QL (2 messages)

    Guys.

    I am using JDeveloper with Oracle AS .........
    I have written a EJB QL like this

    Select object(o) from Countries o where o.countryName like ?1

    whenever I am tyring to run my app, it is throwing this exception

    05/07/25 15:09:52 Encountered "o . countryName like ?1" at line 1, column 7.

    Was expecting one of:

    "(" ...

    "NOT" ...

    "IdentificationVar" "." "CmpField" "NOT" ...

    "IdentificationVar" "." "CmpField" "IN" ...

    "IdentificationVar" "." "CmpField" "LIKE" <CHAR_LITERAL> ...

    "IdentificationVar" "." "CmpField" "LIKE" <STRING_LITERAL> ...

    "IdentificationVar" "." "CmpField" "IS" ...

    "+" ...

    "-" ...

    "IdentificationVar" "." "CmpField" "*" ...

    "IdentificationVar" "." "CmpField" "/" ...

    "IdentificationVar" "." "CmpField" "+" ...

    "IdentificationVar" "." "CmpField" "-" ...

    "IdentificationVar" "." "CmpField" "BETWEEN" ...

    "IdentificationVar" "." "SingleValuedCmrField" ...

    "IdentificationVar" "." "CollectionValuedCmrField" ...

    "IdentificationVar" "NOT" ...

    "IdentificationVar" "MEMBER" ...

    "IdentificationVar" "." "CmpField" "=" ...

    "IdentificationVar" "." "CmpField" ">" ...

    "IdentificationVar" "." "CmpField" ">=" ...

    "IdentificationVar" "." "CmpField" "<" ...

    "IdentificationVar" "." "CmpField" "<=" ...

    "IdentificationVar" "." "CmpField" "<>" ...


    EJB QL statement : 'Select object(o) from Countries o where o.countryName like ?1'
    EJB QL method : public abstract java.util.Collection model.CountriesHome.findByCountryName(java.lang.String) throws javax.ejb.FinderException,java.rmi.RemoteException


    05/07/25 15:09:52 at com.sun.ejb.ejbql.parser.EjbQLParser.parse(EjbQLParser.java:224)

    05/07/25 15:09:52 at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)

    05/07/25 15:09:52 at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerator.java:735)

    05/07/25 15:09:52 at com.sun.ejb.sqlgen.SQLGenerator.generateSQL(SQLGenerator.java:365)

    05/07/25 15:09:52 at com.evermind.server.ejb.deployment.EJBPackage.translateEjbqlQeries(EJBPackage.java:2314)

    05/07/25 15:09:52 at com.evermind.server.ejb.compilation.Compilation.translateEjbqlQeries(Compilation.java:179)

    05/07/25 15:09:52 at com.evermind.server.ejb.compilation.Compilation.compile(Compilation.java:219)

    05/07/25 15:09:52 at com.evermind.server.ejb.compilation.Compilation.doGenerateCode(Compilation.java:271)

    05/07/25 15:09:52 at com.evermind.server.ejb.EJBContainer.postInitBatch(EJBContainer.java:2279)

    05/07/25 15:09:52 at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:2212)

    05/07/25 15:09:52 at com.evermind.server.Application.postInit(Application.java:556)

    05/07/25 15:09:52 at com.evermind.server.Application.setConfig(Application.java:170)

    05/07/25 15:09:52 at com.evermind.server.ApplicationServer.addApplication(ApplicationServer.java:1987)

    05/07/25 15:09:52 at com.evermind.server.ApplicationServer.initializeApplications(ApplicationServer.java:1926)

    05/07/25 15:09:52 at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1482)

    05/07/25 15:09:52 at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:92)

    I am using MYSQL at the back end and I have tested this query with the database and it works fine ... because of the above error it is also unable to load the EJB package.

    Not sure what is going wrong ....
    When i use Select object(o) from Countries o where o.countryName like '?1', then it works but nothing returns from Database which is obvious .............

    help plsss

    Threaded Messages (2)

  2. Subhankar,
    What version opf OC4J/JDeveloper are you using ?

    JDev 9.0.5/10.1.2 have only support for EJB 2.x and EJBQL like support is part of EJB 2.1.

    You can try out JDev 10.1.3 Developer Preview or try deploying to a standalone version of OC4J 10.1.3. These versions have support for EJB 2.1 and hence like support for EJBQL

    -Debu
    http://debupanda.com
  3. http://www.theserverside.com/discussions/thread.tss?thread_id=34660

    check this link and this will help u alott