3 Replies Latest reply on Feb 5, 2014 4:05 AM by vadivel.murugan

    issue in querying the repository content

    vadivel.murugan

      I am beginner to JCR and modeshape

       

      I have an issue in querying the repository content

       

      I tried to create the cars example in modeshape 3.7.1 with infinispan and mysql

       

      I have added the nodes in the following way,

      Node carNode = root.addNode("1000ET");

      n.setProperty("maker", "BMW");

      n.setProperty("model", "xyz");

      n.setProperty("userRating", 5);

      session.save();

       

      and if i try to loop through the nodes, i get this node added to the root node

      NodeIterator it = root.getNodes();

      while (it.hasNext()) {

                Node node = (Node)it.nextNode();

              System.out.println(node.getName());

              System.out.println(node.getPath());

      }

       

      But if i try to make a query in the subsequent lines, it returns 0 rows

      +---+-------------------+-------------------+------------------------+---------------------+-----------------------+-------------------------+------------------------+------------------+------------------+-------------------+------------------------+--------------------+-------------------+----------------+

      | # | car:Car.car:maker | car:Car.car:model | car:Car.car:userRating | car:Car.jcr:created | car:Car.jcr:createdBy | car:Car.jcr:primaryType | car:Car.jcr:mixinTypes | car:Car.jcr:path | car:Car.jcr:name | car:Car.jcr:score | car:Car.mode:localName | car:Car.mode:depth | Location(car:Car) | Score(car:Car) |

      +---+-------------------+-------------------+------------------------+---------------------+-----------------------+-------------------------+------------------------+------------------+------------------+-------------------+------------------------+--------------------+-------------------+----------------+

      +---+-------------------+-------------------+------------------------+---------------------+-----------------------+-------------------------+------------------------+------------------+------------------+-------------------+------------------------+--------------------+-------------------+----------------+

      This is my query

      String jcr_sql2_string = "SELECT * FROM [car:Car]";

      i use javax.jcr.QueryManager to create the query and execute it with javax.jcr.Query

       

      my 'cnd' file entires are,

      <jcr = 'http://www.jcp.org/jcr/1.0'>

      <nt = 'http://www.jcp.org/jcr/nt/1.0'>

      <mix = 'http://www.jcp.org/jcr/mix/1.0'>

      <car = 'http://www.modeshape.org/examples/cars/1.0'>

       

      [car:Car] > mix:created, nt:unstructured

      - car:maker (STRING) COPY

      - car:model (STRING) COPY

      - car:userRating (LONG) COPY < '[1,5]'

       

      Can you let me know where i am wrong and set some direction suitably?