cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrus Adamchik (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAY-1514) ClassCastException when EJQLQuery parameters is null.
Date Tue, 05 Jul 2011 18:17:16 GMT

    [ https://issues.apache.org/jira/browse/CAY-1514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13060050#comment-13060050
] 

Andrus Adamchik commented on CAY-1514:
--------------------------------------

The test case demonstrates a problem, albeit it seems to be a different one (NPE vs. ClassCastException)
:

Caused by: java.lang.NullPointerException
	at org.apache.cayenne.access.jdbc.EJBQLPathTranslator.processLastPathComponent(EJBQLPathTranslator.java:190)
	at org.apache.cayenne.access.jdbc.EJBQLPathAnaliserTranslator.visitPath(EJBQLConditionTranslator.java:1181)
	at org.apache.cayenne.access.jdbc.EJBQLConditionTranslator.processParameter(EJBQLConditionTranslator.java:852)
	at org.apache.cayenne.access.jdbc.EJBQLConditionTranslator.visitPositionalInputParameter(EJBQLConditionTranslator.java:773)
	at org.apache.cayenne.ejbql.parser.EJBQLPositionalInputParameter.visitNode(EJBQLPositionalInputParameter.java:34)

I wonder if we have 2 separate problems at hand, and need an extra test case to reproduce
the one described by the Jira reporter. One difference with the test case (that may or may
not be relevant) is that path matched against NULL is multi-part, traversing the relationship.


Re: .jjt patch: I am confused about the assymetry between these 2 chunks:

@@ -693,7 +693,8 @@ void literal_or_param() : { }
 
 void like_expression() #Like : { }
 {
-	string_expression() [<NOT> { jjtThis.not = true; }] <LIKE> pattern_value() 
+	string_expression() [<NOT> { jjtThis.not = true; }] <LIKE> 
+	((input_parameter() [(<ESCAPE> escape_character())]) | pattern_value())  
 }
 
and

@ -1208,8 +1209,7 @@ void positional_input_parameter() #PositionalInputParameter :
 
 void pattern_value() #PatternValue : { }
 {
-	(input_parameter() | string_literal())
-	[(<ESCAPE> escape_character())]
+	string_literal() [(<ESCAPE> escape_character())]
 }

Could you explain the fix?


> ClassCastException when EJQLQuery parameters is null.
> -----------------------------------------------------
>
>                 Key: CAY-1514
>                 URL: https://issues.apache.org/jira/browse/CAY-1514
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0.1
>         Environment: Tomcat 6.0.26
>            Reporter: Marek Ĺ abo
>         Attachments: cayST.txt, ejbql-null-parameters.patch, test.patch
>
>
> When a parameter in EJBQLQuery is set to null, an error occurs which results in ClassCastException.
When parameter is not null query is executed as expected.
> It is duplicable with following/similar code:
>         EJBQLQuery eq = new EJBQLQuery("SELECT COUNT(u) FROM User u WHERE u.username
like :usernam AND u.userInfo.name like :userName");
>         eq.setParameter("userName", null);
>         eq.setParameter("usernam", "msabo");
>         return (Long) DataObjectUtils.objectForQuery(getObjectContext(), eq);
> Full stack trace is in attachment.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message