facebook

EJB QL LIKE operator

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #219473 Reply

    Murtuza
    Member

    Hello,

    I want to perform search by keyword on all fields of a table. Say I have a product table with following fields:

    Field Name Data Type
    ProductNo Integer
    ProductName String
    Brand String
    UnitPrice Double
    SupCode Integer

    I cannot use LIKE operator as follows:
    “SELECT OBJECT(p) FROM Product AS p WHERE p.productName LIKE ?1 or p.supCode LIKE ?1 or p.partNo LIKE ?1 p.brand LIKE ?1 or p.unitPrice LIKE ?1 ORDER BY p.productName ASC”

    This throws error as LIKE operator expects String fields only. Is there any way I can use LIKE operator or any other way to search by keywords on all field of any data type using EJB QL.

    #219499 Reply

    Riyad Kalla
    Member

    You might have better luck looking at EJB QL tutorials or googling for this… I don’t know that anyone here is a EJBQL guru.

    Maybe one of our users knows?

    #219651 Reply

    klingmank
    Member

    The EJB 2.0 spec specifies that only string literals may be used as pattern values of LIKE expressions. While the EJB 2.1 spec says that ?x expressions can be used, I’m doubt that anyone has implmented it.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: EJB QL LIKE operator

You must be logged in to post in the forum log in