On Tue, 2004-01-13 at 20:21, Patrick Bakker wrote: > Iʼve been trying to get the following select method code to work in an > EJB I call Product: > > > > /** > > * @ejb.select > > * signature="java.util.Collection ejbSelectNameMatch(String > nameMatch)" > > * query="SELECT OBJECT(p) FROM Product p WHERE p.name LIKE > ?1" ... > However, when I deploy it to a JBoss 3.2.3 server it fails to compile > the EJB-QL, stopping on the LIKE ?1 portion of the EJB-QL.
According to the EJB 2.0 spec, section 11.2, "Input parameters can only be used in comparison_expressions or collection_member_expressions, as defined in Section 11.4". If you look at the definition of simple_cond_expression in that BNF definition, you'll see that LIKE expressions aren't either of these (nor are IN or BETWEEN expressions), so it's not valid to use a ?x parameter in them. The pattern-value of a LIKE expression must be "a string literal" (section 11.2.7.9). Hence the error messages you are seeing: > Error compiling EJB-QL statement 'SELECT OBJECT(p) FROM Product p > WHERE p.name LIKE ?1'; - nested throwable: > (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "1" at > line 1, column 51. > > Was expecting: > > <STRING_LITERAL> ... > > )] For what it's worth, in the 2.1 spec it's changed to say "The pattern_value is a string literal or a string-valued input parameter". So I guess you just need a newer version of JBoss which supports EJB 2.1 (assuming there is one; I don't use it myself so don't know if there is). > The odd thing is that I have finder methods using the same syntax > which compile and work fine. The only difference between the finder > and select method that Iʼve noticed is that I can supply an > SQL-specific query to override the otherwise generated query for the > finder methods. I have not yet found a way to do the same for the > select methods. Is this possible? Any QL extensions or other ways to override the query is going to be specific to each app server, so I presume you're talking about the @jboss.declared-sql tag? Although its description says "Configures a custom query (defined by @ejb.finder)", so far as I can tell you should be able use it for the select queries as well. The signature parameter just specifies a <query-method> from the ejb-jar.xml, and those are generated for select methods as well as finders. Andrew. ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
