jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Kennedy <da...@us.ibm.com>
Subject Date comparison queries
Date Fri, 30 Jun 2006 15:54:06 GMT
Is the <= operator working correctly for dates in query?  The following 
testcase compares 2 dates and I'd expect <= to succeed, but it fails.  The 
>= succeeds though.  Am I misinterpreting the query?  Anybody else seen 
this?


      String nodeName = "testDateQuery";
      Node root = session.getRootNode();

      Node testNode = root.addNode(nodeName, "nt:unstructured");
      try {
              Calendar cal = 
ISO8601.parse("1971-01-01T01:01:01.001+00:00");
              testNode.setProperty("testDate", 
session.getValueFactory().createValue(cal));
 
              session.save();
 
              QueryManager qm = session.getWorkspace().getQueryManager();
              Query q = qm.createQuery("/jcr:root//*[@testDate <= 
'1972-02-01T02:02:02.002+00:00']", Query.XPATH);
              QueryResult qResult = q.execute();

              if (qResult.getNodes().getSize() < 1){
                System.out.println("<= FAILED");
              } else {
                System.out.println("<= SUCCESS");
              }

              q = qm.createQuery("/jcr:root//*[@testDate >= 
'1972-02-01T02:02:02.002+00:00']", Query.XPATH);
              qResult = q.execute();

              if (qResult.getNodes().getSize() < 1){
                System.out.println(">= FAILED");
              } else {
                System.out.println(">= SUCCESS");
              }
      } finally {
        testNode.remove();
        session.save();
      }

David 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message