no worries i  got it fixed....I dont know how it was working in
previous version
I was declaring params ina loop of Map which i pass to this function
Map crit;//this is  being passed to this function
//i create another paramMap which will be passed to
query.executeWithMap();
for(String key:crit.keySet())
                        {
                                fieldName = getFieldName(key);
                                value = crit.get(key);
                                paramName = "p_" + fieldName;
                                paramMap.put(paramName, value);
                                
query.declareParameters(getClassType(value.getClass
().getName())+ " "+ paramName);
                        }

above code was working..and i think it was buggy as per JDO
standards.... as i thought one call to declareParameters set one param
and if i call 2 times it will se two params..but not true, all the
params need to be set at once with comma seprated, so i changed the
loop like this
                        for(String key:crit.keySet())
                        {
                                fieldName = getFieldName(key);
                                value = crit.get(key);
                                paramName = "p_" + fieldName;
                                paramMap.put(paramName, value);
                                System.out.println("New Declare Param = " 
+getClassType
(value.getClass().getName())+ " "+ paramName +":"+value);
                                if(!"".equals(declareParamString))
                                        declareParamString = declareParamString 
+ "," +getClassType
(value.getClass().getName())+ " "+ paramName;
                                else
                                        declareParamString = 
getClassType(value.getClass().getName())+ "
"+ paramName;
                        }
                        System.out.println("New Declare Param = " 
+declareParamString);
                        query.declareParameters(declareParamString);

Ravi.




On Aug 29, 12:44 am, Ravi Sharma <[email protected]> wrote:
> Hi,
> I am creating a query as follows, it was working before and then i upgraded
> to SDK1.2.2  and it stopped working
>
>             criteria = "mainPost=p_mainPost and category=p_category";
>             query = pm.newQuery(Post.class,criteria);
>
>             Map<String,Object> paramMap = new HashMap<String,Object>();
>             paramMap.put("p_mainPost","Y");
>             paramMap.put("p_category","Altenrating Current");
>
>             query.setRange(0, 100);
>             query.setOrdering("creationDate desc");
>
>             try{
>             results = (List) query.executeWithMap(paramMap);
>             }catch(Exception ex)
>             {
>                 System.out.println("Exception occured "+ ex.getMessage());
>
>             }
>
> and i get the exception
>
>  Exception occured Problem with query <SELECT FROM
> com.next.sc.server.entity.Post WHERE mainPost== p_mainPost  &&
> category== p_category PARAMETERS java.lang.String p_category ORDER BY
> creationDate desc RANGE 0,10>: Right side of expression is of
> unexpected type: org.datanucleus.query.expression.VariableExpression
>
> Please help, its really annoying that i didnt change any thing in code and
> just upgrade of 1.2.2 is giving me this problem. Luckily i created another
> version of my application on upgrade, so now one version is working and
> another one is not, both have same source code except some jsp changes.
>
> Working Version 1 
> linkhttp://1.latest.sciencecanteen.appspot.com/postList.htm?cat=Altenrati...
>
> Not Working version 2 
> linkhttp://2.latest.sciencecanteen.appspot.com/postList.htm?cat=Altenrati...<http://1.latest.sciencecanteen.appspot.com/postList.htm?cat=Altenrati...>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to