This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes string function LOCATE of EJB-QL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "string function LOCATE of EJB-QL" Watch "string function LOCATE of EJB-QL" New topic
Author

string function LOCATE of EJB-QL

Christian D. Th. Sellberg
Greenhorn

Joined: Apr 02, 2004
Posts: 10
Hi All,

I have a question about the string function LOCATE of EJB-QL.

The book Enterprise JavaBeans by Monson-Haefel says that the correct use of the LOCATE method is as exemplified by

SELECT OBJECT(c) FROM Customer c WHERE � LOCATE(c.lastName, �Monson�)>-1

This query is supposed to return all Customers having �Monson� in their last name, but in Jboss 4.0 it only works when you write

SELECT OBJECT(c) FROM Customer c WHERE � LOCATE( �Monson�, c.lastName)>0.

I.e. in Jboss the string index starts at 1 (like in JDBC), not found returns 0, and the order of the arguments to LOCATE are the opposite as in Monson-Haefels example.

The specification does not specify the use of LOCATE but refer to a book

quote:
---
These functions are a subset of the functions defined for JDBC 2.0 drivers, as described in Appendix A in JDBC API tutorial and Reference, Second Edition.�
---

I do not have the book �JDBC API tutorial and Reference, Second Edition� at the time of writing.

What is the correct use of LOCATE? Is it JBoss or Monson-Haefel who got it right?

Kind regards
Christian

[ July 10, 2004: Message edited by: Christian Dauer Th. Sellberg ]
[ July 10, 2004: Message edited by: Christian Dauer Th. Sellberg ]
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
The spec not only doesnt define the return value explicitly, the reference to another book is only made in small font found under the bottom of the page. I dont understand why such an important information is treated with such an indifferent attitude.
 
Don't get me started about those stupid light bulbs.
 
subject: string function LOCATE of EJB-QL