1 Reply Latest reply: Sep 3, 2013 7:46 AM by Nitin Khare RSS

    Repository Question

    AASH

      <!-- The "book" item type -->

      <item-descriptor name="book" default="true">

      <table name="book" type="primary" id-column-names="book_id">

      <property name="title"/>

      <property name="author" item-type="author" column-name="author_id"/>

      </table>

      </item-descriptor>

       

       

      <!-- The "author" item type -->

      <item-descriptor name="author">

      <table name="author" id-column-names="author_id" type="primary">

      <property name="lastName"/>

      <property name="city"/>

      <property name="state"/>

      <property name="zip"/>

      </table>

      <table name="book" id-column-names="author_id" type="multi">

      <property name="books_written" data-type="set"

      component-item-type="book"

      column-name="book_id"/>

      </table>

      </item-descriptor>

       

       

       

       

       

      DB Values

       

      last name : Vincent

      Book1 : xyz

      Book2 : abc

       

      last name : jhon

      Book1 : pqr

      Book2 : abc

       

       

      How do i use Query builder or RQL to get all authors who have written Book - abc

        • 1. Re: Repository Question
          Nitin Khare

          I think it would be apt if the repository definition you have mentioned should have many-to-many relationship between book and author. The reason I'm saying this is because a book can have multiple authors and the same author can also have written multiple books. Anyways coming on to the RQL to get all authors who have written a particular book, I think you can do it using INCLUDES ITEM. Try this RQL on author item:

           

          books_written INCLUDES ITEM (title="abc")
          

           

          or from dyn/admin run following XML operation on your repository component

           

          <query-items item-descriptor="author">books_written INCLUDES ITEM (title="abc")</query-items>
          

           

          See if it serves your purpose.