Next Previous Index

5. Collection (raw data)


Definition:

A raw data collection is a collection on a first-rank class that contains second-rank classes. First- rank class A holds a reference to a set of second-rank class B instances. This is not limited to full classes - B could even be of primitive type.


Scenario:

We have one first-rank class, Foo, and a collection of Strings (e.g. people's names)


Set Foo.getPeople() // returns a collection of String instances

Hibernate Mapping:

In Hibernate, this could be mapped as follows:


<class name="Foo" table="foo">
     ...
     <set role="people" table="Person">
           <key column="foo_id"/>
          <element column="name" type="string"/>
     </set>
</class>

Table Schema:

Foo

id

Person

foo_id

name


Note that Person does not represent a first-rank class. It is simply a collection of second-rank persistent data - in this case String objects.


Bidirectionality:

There's no bidirectional relationship available here as there is only one first-rank class involved.



Next Previous Index