You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Andrey Razumovsky <ra...@gmail.com> on 2009/11/10 12:50:14 UTC

EJBQL doesn't support null parameters

Hi,

Currently EJBQL parameter cannot be set as null. Test is simple as follows:

EJBQLQuery query = new EJBQLQuery("select p from Painting p WHERE
p.toArtist=:x");
query.setParameter("x", null);
createDataContext().performQuery(query);

Caused by: java.lang.ClassCastException:
org.apache.cayenne.reflect.generic.DataObjectToOneProperty cannot be cast to
org.apache.cayenne.reflect.AttributeProperty
    at
org.apache.cayenne.access.jdbc.EJBQLConditionTranslator.processParameter(EJBQLConditionTranslator.java:708)
    at
org.apache.cayenne.access.jdbc.EJBQLConditionTranslator.visitNamedInputParameter(EJBQLConditionTranslator.java:345)

Is it OK or this is a bug? I mean, is this case covered by JPA spec, since
it i think we still should keep it where possible

Re: EJBQL doesn't support null parameters

Posted by Andrus Adamchik <an...@objectstyle.org>.
Probably a bug. I though that worked though.

On Nov 10, 2009, at 1:50 PM, Andrey Razumovsky wrote:

> Hi,
>
> Currently EJBQL parameter cannot be set as null. Test is simple as  
> follows:
>
> EJBQLQuery query = new EJBQLQuery("select p from Painting p WHERE
> p.toArtist=:x");
> query.setParameter("x", null);
> createDataContext().performQuery(query);
>
> Caused by: java.lang.ClassCastException:
> org.apache.cayenne.reflect.generic.DataObjectToOneProperty cannot be  
> cast to
> org.apache.cayenne.reflect.AttributeProperty
>    at
> org 
> .apache 
> .cayenne 
> .access 
> .jdbc 
> .EJBQLConditionTranslator 
> .processParameter(EJBQLConditionTranslator.java:708)
>    at
> org 
> .apache 
> .cayenne 
> .access 
> .jdbc 
> .EJBQLConditionTranslator 
> .visitNamedInputParameter(EJBQLConditionTranslator.java:345)
>
> Is it OK or this is a bug? I mean, is this case covered by JPA spec,  
> since
> it i think we still should keep it where possible