persistence@glassfish.java.net

Re: code review for issue 343

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Wed, 15 Mar 2006 14:57:01 +0100

Hi Jielin,

looks good!

Two remarks:

(1) The method LikeNode.validate does not need to call validateParameter
on the escape node. The validate method in EscapeNode will do this.

(2) According to the spec the expected type of an ESCAPE input parameter
is char or Character and not String. This is from section "4.6.9 Like
Expressions":
The optional escape_character is a single-character string literal or a
character-valued input parameter (i.e., char or Character) ...
So the call validateParameter in EscapeNode needs to get char as the
expected type:
   left.validateParameter(context, typeHelper.getCharType());
This means you cannot pass a string as the actual value of the ESCAPE
input parameter. You need to use something like new Character('\\').

Regards Michael


> Hi, Tom/Michael,
>
> Here is the change for issue 343 - EJBQL parser does not accept input
> parameter as ESCAPE character
>
> The current EJBQL compiler does not accept an input parameters as escape
> character. It only supports escape as a single string literal. I added
> parameter handling for escape.
>
> File changed:
> src/java/oracle/toplink/essentials/expressions/Expression.java - add a
> new like method to accept two expression arguments.
> src/java/oracle/toplink/essentials/internal/parsing/EscapeNode.java -
> add generateExpression method
> src/java/oracle/toplink/essentials/internal/parsing/LikeNode.java - use
> generateExpression method for escape
> src/java/oracle/toplink/essentials/internal/parsing/NodeFactoryImpl.java
> - use left node for escape character
> src/java/oracle/toplink/essentials/internal/parsing/ejbql/antlr273/EJBQLParser.g
> - add likeValue method for handling escape as input parameter
>
> Please review the change.
>
> Thanks.
>
> Jielin