This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB QL LIKE Operator Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "EJB QL LIKE Operator" Watch "EJB QL LIKE Operator" New topic
Author

EJB QL LIKE Operator

Murtuza N Vohra
Greenhorn

Joined: Nov 15, 2004
Posts: 4
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.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. LIKE is String comparison, which won't work with other datatypes.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Murtuza N Vohra
Greenhorn

Joined: Nov 15, 2004
Posts: 4
Is there any other way we can write EJB QL statement to search in all table fields of any data type.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: EJB QL LIKE Operator
 
Similar Threads
Auto Format insert into....?
EJB QL RETURNING ONLY THE FIRST RECORD OF THE TABLE
Problem with EJB-QL and primary-keys
a cmr-field and a cmp-field on the bean are using the same name. The names
Auto Format data for Insert into...?