• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string function LOCATE of EJB-QL

 
Christian D. Th. Sellberg
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic