You can also specify that a repository item property references other repository items. In the previous example, an author may have written more than one book. Instead of the book property in the preceding example, this next example uses a books_written property whose value is a Set of book repository items. The <property> tag for the books_written property uses the following attributes:

<!-- 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"/>

<!-- 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 name="book" id-column-names="author_id" type="multi">
    <property name="books_written" data-type="set"

In this example, the repository definition XML defines the book table twice: in the book item descriptor and in the author item descriptor. In the author item descriptor, the <table> tag for the book table includes the attribute type="multi", indicating that each author item can have more than one row with the id column. In a multi-table, all defined attributes are multi-valued types. To define Array, List and Map types, you also must specify a multi-column-name attribute on the table tag. This specifies which column to use as the sorting value in order to determine the order of the List and the key for the Map.

Now the properties author and books_written are actually real beans (in this case RepositoryItems) instead of just simple Java primitives. In the author item descriptor, the books_written property is a Set of RepositoryItems that correspond to books. The other types supported are List, Map, and Array.

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices