Creating your own ATG Repository - Beginners- III

We will be covering the Multi Table, referencing other repositories and One to Many relation in between same repository.

Must read Points:
1. Multi table is used to maintain one to Many relations between Items.
2. Multi table can hold Map, List or Set of items.
3. One item-descriptor can hold N number of Multi tables.

Simple Table below explains concepts of Map, List and Set.


Type\Conditions
Data-type=
multi-column-name=
Set
“set”
Not Required
List
“list”
Seq_number of type “int”(acts as sequence)
Map
“map”
String which acts as key

4. component-item-type if multi valued property needs to be referenced, else component-data-type.
5. id-column-name should be same of primary table.

Step 1: Analyse the Table and data-type.



We will be using "set" to store the Books.

Step 2: Add the Multi column to "author" item.

<item-descriptor name="author" display-name="author" >
   
    <table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    </table>
   
    <table name="AUTHOR_BOOKS" type="multi" id-column-names="author_id">
        <property name="books" column-names="book" display-name="books" data-type="set" component-item-type="book"/>
    </table>
</item-descriptor>

Step 3: Author has primary address, which references to Address Repository.




We will add one more column to primary table of "author" item and reference to Address Repository.

Step 4: Add column to Primary table of "author" item and reference.

<table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    <property name="address" column-names="address" display-name="address" item-type="address" repository="/my/Address"/>
    </table>


repository will hold the referenced repository's Component Path.

7 comments:

  1. Best writeup i have ever read explaining ATG Repository.. Thank you ..

    ReplyDelete
  2. Thanks you . It helps a lot for beginners.

    ReplyDelete
  3. thnx a lot ... m appearing for certification .. hope dis helps me in some way :) .. keep up the good work

    ReplyDelete
  4. thx..
    my all dough is clear

    ReplyDelete
  5. Hi,
    Can u please tell me how to persist the data in DB in case of one to many relationship. Like which item descriptor to use, and how to populate the multi table's attribute. It would be very helpful of you if you can post the java class example.
    Thank you.
    Sandeep
    sharma.sandeep1024@gmail.com

    ReplyDelete
  6. thank you for making great understanding

    ReplyDelete
  7. thank you for making great understanding

    ReplyDelete