Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

string function LOCATE of EJB-QL

 
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 ]
 
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.
 
mooooooo ..... tiny ad ....
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic