Index: src/main/java/com/xpn/xwiki/objects/classes/ListClass.java
===================================================================
--- src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	(working copy)
@@ -688,14 +688,22 @@
             return;
         }
 
+        // if multiselect
+        // :category member of obj.category
+        // otherwise 
+        // :category = obj.category
+        String separator = isMultiSelect() ? " member of " : " = ";
+
+
+ 
         if (values instanceof String) {
             // general comparison '=' - tests at least one value =
-            criteriaList.add("@xp:" + getName() + "='" + values.toString() + "'");
+            criteriaList.add("'" + values.toString() + "'" + separator  + getFullQueryPropertyName());
         } else {
             String[] valuesarray = (String[]) values;
             String[] criteriaarray = new String[valuesarray.length];
             for (int i = 0; i < valuesarray.length; i++) {
-                criteriaarray[i] = "@xp:" + getName() + "='" + valuesarray[i] + "'";
+                criteriaarray[i] = "'" + valuesarray[i] + "'" + separator + getFullQueryPropertyName();
             }
             criteriaList.add("(" + StringUtils.join(criteriaarray, " or ") + ")");
         }
Index: src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java
===================================================================
--- src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	(working copy)
@@ -21,6 +21,9 @@
 package com.xpn.xwiki.objects.classes;
 
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.ecs.xhtml.div;
@@ -372,11 +375,17 @@
         select.setSize(3);
         String String0 = getDisplayValue(context, 0);
         String String1 = getDisplayValue(context, 1);
+        String fieldFullName = getFieldFullName();
+        Number[] selectArray = ((Number[]) criteria.getParameter(fieldFullName));
+        List<Number> selectlist = (selectArray != null) ? Arrays.asList(selectArray) : new ArrayList<Number>();
 
-        option[] options = {new option("---", ""), new option(String1, "1"), new option(String0, "0")};
-        options[0].addElement("---");
-        options[1].addElement(String1);
-        options[2].addElement(String0);
+        option[] options = {new option(String1, "1"), new option(String0, "0")};
+        options[0].addElement(String1);
+        options[1].addElement(String0);
+        if (selectlist.contains(new Integer(1)))
+         options[0].setSelected(true); 
+        if (selectlist.contains(new Integer(0)))
+         options[1].setSelected(true); 
 
         /*
          * try { IntegerProperty prop = (IntegerProperty) object.safeget(name); if (prop!=null) { Integer ivalue =
@@ -408,13 +417,33 @@
     }
 
     @Override
+    public void makeQuery(Map<String, Object> map, String prefix, XWikiCriteria query, List<String> criteriaList)
+    {
+        Object values = map.get(prefix);
+        if ((values == null) || (values.equals(""))) {
+            return;
+        }
+
+        // :value = doc.object(XWiki.ArticleClass).category
+
+        Number[] valuesarray = (Number[]) values;
+        String[] criteriaarray = new String[valuesarray.length];
+        for (int i = 0; i < valuesarray.length; i++) {
+            criteriaarray[i] =  "" + valuesarray[i] + " = " + getFullQueryPropertyName();
+        }
+        criteriaList.add("(" + StringUtils.join(criteriaarray, " or ") + ")");
+        return;
+    }
+
+
+    @Override
     public void fromSearchMap(XWikiQuery query, Map<String, String[]> map)
     {
         String[] data = map.get("");
         if (data != null) {
-            Object[] data2 = new Object[data.length];
+            Number[] data2 = new Number[data.length];
             for (int i = 0; i < data.length; i++) {
-                data2[i] = fromString(data[i]).getValue();
+                data2[i] = (Number) fromString(data[i]).getValue();
             }
             query.setParam(getObject().getName() + "_" + getName(), data2);
         }
Index: src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java
===================================================================
--- src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java	(working copy)
@@ -594,4 +594,8 @@
 
         return result;
     }
+    
+    protected String getFullQueryPropertyName() {
+        return "obj." + getName();
+    }
 }
Index: src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java
===================================================================
--- src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java	(working copy)
@@ -187,19 +187,19 @@
     {
         Number value = (Number) map.get(prefix);
         if ((value != null) && (!value.equals(""))) {
-            criteriaList.add("@xp:" + getName() + "=" + value.toString());
+            criteriaList.add(getFullQueryPropertyName() + "=" + value.toString());
             return;
         }
 
         value = (Number) map.get(prefix + "lessthan");
         if ((value != null) && (!value.equals(""))) {
-            criteriaList.add("@xp:" + getName() + "<=" + value.toString());
+            criteriaList.add(getFullQueryPropertyName() + "<=" + value.toString());
             return;
         }
 
         value = (Number) map.get(prefix + "morethan");
         if ((value != null) && (!value.equals(""))) {
-            criteriaList.add("@xp:" + getName() + ">=" + value.toString());
+            criteriaList.add(getFullQueryPropertyName() + ">=" + value.toString());
             return;
         }
     }
Index: src/main/java/com/xpn/xwiki/objects/classes/StringClass.java
===================================================================
--- src/main/java/com/xpn/xwiki/objects/classes/StringClass.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/objects/classes/StringClass.java	(working copy)
@@ -151,24 +151,24 @@
             String startsWith = (String) map.get(prefix + "startswith");
             String endsWith = (String) map.get(prefix + "endswith");
             if ("1".equals(startsWith)) {
-                criteriaList.add("jcr:like(@xp:" + getName() + ", '" + value + "%')");
+                criteriaList.add("lower(" + getFullQueryPropertyName() + ") like '" + value.toLowerCase() + "%'");
             } else if ("1".equals(endsWith)) {
-                criteriaList.add("jcr:like(@xp:" + getName() + ", '%" + value + "')");
+                criteriaList.add("lower(" + getFullQueryPropertyName() + ") like '%" + value.toLowerCase() + "'");
             } else {
-                criteriaList.add("jcr:like(@xp:" + getName() + ", '%" + value + "%')");
+                criteriaList.add("lower(" + getFullQueryPropertyName() + ") like '%" + value.toLowerCase() + "%'");
             }
             return;
         }
 
         value = (String) map.get(prefix + "exact");
         if ((value != null) && (!value.equals(""))) {
-            criteriaList.add("@xp:" + getName() + "='" + value + "'");
+            criteriaList.add(getFullQueryPropertyName() + "='" + value + "'");
             return;
         }
 
         value = (String) map.get(prefix + "not");
         if ((value != null) && (!value.equals(""))) {
-            criteriaList.add("@xp:" + getName() + "!='" + value + "'");
+            criteriaList.add(getFullQueryPropertyName() + "!='" + value + "'");
             return;
         }
     }
Index: src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java
===================================================================
--- src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java	(revision 34430)
+++ src/main/java/com/xpn/xwiki/plugin/query/QueryPlugin.java	(working copy)
@@ -312,28 +312,25 @@
     }
 
     public String makeQuery(XWikiQuery query) throws XWikiException {
-        StringBuffer xpath = new StringBuffer();
+        StringBuffer xwqlfrom = new StringBuffer();
+        StringBuffer xwqlwhere = new StringBuffer();
+        StringBuffer xwqlorder = new StringBuffer();
+        
         Set classes = query.getClasses();
         if (classes.size()>1)
          throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_SEARCH_NOTIMPL, "Search with more than one class is not implemented");
         if (classes.size()==0)
-         return "/*/*";
+         return "";
 
         String className = (String) classes.toArray()[0];
         BaseClass bclass = context.getWiki().getClass(className, context);
-        xpath.append("/*/*/obj/");
-        xpath.append(className.replaceAll("\\.", "/"));
-        String where= bclass.makeQuery(query);
-        if (!where.equals(""))
-        {
-            xpath.append("[");
-            xpath.append(where);
-            xpath.append("]");
+        xwqlfrom.append("doc.object(" + className + ") as obj");
+        String where = bclass.makeQuery(query);
+        if (!where.equals("")) {
+            xwqlwhere.append(where);
         }
-        xpath.append("/jcr:deref(@doc, '*')/@fullName");
 
         List oProps = query.getOrderProperties();
-        String orderClause = "";
         if ((oProps!=null)&&(oProps.size()>0)) {
             for (int i=0;i<oProps.size();i++) {
                 OrderClause clause = (OrderClause) oProps.get(i);
@@ -343,22 +340,25 @@
                     String propClassName = propPath.substring(0, i1);
                     if (propClassName.equals(className)) {
                         String propName = propPath.substring(i1+1);
-                        if (!orderClause.equals("")) {
-                            orderClause += " and ";
+                        if (xwqlorder.length()!=0) {
+                        	xwqlorder.append(",");
                         }
-                        orderClause += "@xp:" + propName;
+                        xwqlorder.append("obj." + propName);                      
                         if (clause.getOrder()==OrderClause.DESC)
-                            orderClause += " descending";
+                        	xwqlorder.append(" desc");
                     }
                 }
             }
         }
-        if (!orderClause.equals("")) {
-            xpath.append(" order by ");
-            xpath.append(orderClause);
+        
+        String xwql = "from " + xwqlfrom.toString();
+        if (xwqlwhere.length()!=0)
+          xwql += " where " + xwqlwhere.toString();
+        if (xwqlorder.length()!=0) {
+           xwql += " order by " + xwqlorder.toString();
         }
 
-        return xpath.toString();
+        return xwql;
     }
 
     /*
