next up previous contents
Next: Abstracting data views Up: Storing in the Database Previous: End-dating   Contents


Suppose we wished to add an Address to a User. But a type like Address has a one to one relationship with User and there is no need to store it in a separate table in the database, the directive inline=''true'' will define the columns of address inside of the user table. The prefix tag allows an optional prefix to be concatenated to the columns defined in the inline-type
<class name="${user.pkg}.Address"
   <!-- oid is defined but not used when inlined -->
    <field name="oid" type="integer">
       <sql name="ad_oid" />
	<field name="street" type="string" len="64">
      <sql name="ad_street" />
    <field name="city" type="string" len="20">
      <sql name="ad_city" />
    <field name="state" type="string" len="2">
      <sql name="ad_state" />
To include some address in class user the syntax would be.
<class name="${user.pkg}.User"
      identity="oid" end-date="true">
   <field name="homeAddress" type="${user.pkg}.Address" >
      <sql name="ad" inline="true" prefix="home" />
   <field name="workAddress" type="${user.pkg}.Address" >
      <sql name="ad" inline="true" prefix="work" />