5 Replies Latest reply on Apr 1, 2014 7:08 PM by Van Halbert

    Using DSL and trying to use reflections to drive building the query

    Van Halbert Master

      Looking to add support for querying a remote Infinispan instance via hot rod client using DSL.   And in building the queries, wanting to use metadata derived from the objects (using reflections), to specify the entity and attributes when dynamically building the queries.   But one issue that I see, based on using your remote-query quick start, is the attribute names to be used in the query look to have to match what was defined in the .proto file (i.e., address book.proto), not what the attribute name is in the java class.   Example query:

       

      addressbook.proto:

      {code}

         message PhoneNumber {

            required string number = 1;

            optional PhoneType type = 2 [default = HOME];

         }

       

         repeated PhoneNumber phone = 4;

      {code}

       

      And what's defined in Person.java is:

      {code}

      ...

      private List<PhoneNumber> phones;

      ...

         public List<PhoneNumber> getPhones() {

            return phones;

         }

      {code}


      And in your test client, AddressBookManager.java, to query a phone number, it defines the query as:


      {code}

           Query query = qf.from(Person.class)

                  .having("phone.number").eq(phoneNumber).toBuilder()

                  .build();

      {code}

       

      So this worries me that reflections on the object(s) won't provide the correct metadata, and what assumptions must be implemented to correct plurals (or anything else) in order to map names correctly. 

       

      Can you tell me if my assumptions about this are correct?  And if so, what thoughts would you have about solving the metadata mapping issue.

       

      Thanks.

       

      Van