Bugs item #538802, was opened at 2002-04-03 10:25
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=538802&group_id=22866

Category: JBossCMP
Group: v3.0 Rabbit Hole
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Eric Jain (ejain)
Assigned to: Dain Sundstrom (dsundstrom)
Summary: LOCATE(bean.field, ?1)

Initial Comment:
LOCATE(bean.field, ?1) returns all rather than just 
the matching records.

<query>
  <query-method>
    <method-name>findByPartialName</method-name>
    <method-params>
      <method-param>java.lang.String</method-param>
    </method-params>
  </query-method>
  <ejb-ql>
    <![CDATA[
      SELECT OBJECT(s) FROM Service s WHERE LOCATE
(s.name, ?1) > -1
    ]]>
  </ejb-ql>
</query>


2002-04-03 18:07:23,080 DEBUG 
[org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.ServiceE
JB.findByPartialName] Executing SQL: SELECT t0_s.id 
FROM ServiceEJB t0_s WHERE locate(t0_s.name, ?, 1) > -1


----------------------------------------------------------------------

>Comment By: Dain Sundstrom (dsundstrom)
Date: 2002-04-09 10:58

Message:
Logged In: YES 
user_id=251431

If the string is not found the return value is 0, so your 
query return every entity.

The EJB-QL functions are based on the JDBC fucntion, which 
in turn are based on the Microsoft ODBC Core 
specification.  This spec 
(http://msdn.microsoft.com/library/en-
us/odbc/htm/odbcstring_functions.asp) says the following:

Returns the starting position of the first occurrence of 
string_exp1 within string_exp2. The search for the first 
occurrence of string_exp1 begins with the first character 
position in string_exp2 unless the optional argument, 
start, is specified. If start is specified, the search 
begins with the character position indicated by the value 
of start. The first character position in string_exp2 is 
indicated by the value 1. If string_exp1 is not found 
within string_exp2, the value 0 is returned. 

----------------------------------------------------------------------

Comment By: Marco Ladermann (mpl)
Date: 2002-04-09 10:33

Message:
Logged In: YES 
user_id=246541

According to the JDBC specification (to which the 
EJB 2.0 specification refers) locate returns 0 if 
the first string argument is not contained in the 
second argument. Therefore your "locate(s.name, 
?1) > -1" is always true. 
 
Marco 
 

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=538802&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to