<document>
  <header>
    <product>resin-ee</product>
    <title>One-to-One Entity Relationship</title>
    <description>
      <p>Using XDoclet to generate a 1-1 relation.</p>

      <p>Scenario: At Hogwarts every Professor teaches one
      Course. The Headmaster keeps track with two 1-1-related CMP
       beans</p> 
      <p>This example focuses on:</p>
      <ul>
        <li>Establishing a one-to-one relationship between two entity beans</li>
        <li>Setting up the database for a one-to-one relationship</li>
      </ul>
    </description>
    <type>tutorial</type>
    <tutorial-startpage>xclient</tutorial-startpage>
  </header>

  <body>
    <summary/>

<section title="Beans">

<example title="CourseBean.java">
package example;

/**
 * @ejb.bean name="course" view-type="local" type="CMP"
 *           reentrant="False" schema="courses" primkey-field="name"
 * @ejb.pk class="java.lang.String"
 * @ejb.home generate="local" local-class="example.CourseHome"
 * @ejb.interface generate="local" local-class="example.Course"
 *
 * @ejb.finder signature="java.util.Collection findAll()"
 *             query="SELECT o FROM courses o"
 *
 * @resin-ejb.entity-bean sql-table="one2one_courses"
 */
abstract public class CourseBean
  extends com.caucho.ejb.AbstractEntityBean {
  /**
   * @ejb.interface-method
   * @ejb.persistent-field
   * @ejb.pk-field
   */
  abstract public String getName();
  /**
   * @ejb.interface-method
   * @ejb.relation name="course-teacher"
   */
  abstract public Teacher getTeacher();
}
</example>

<example title="TeacherBean.java">
package example;

/**
 * @ejb.bean name="teacher" view-type="local" type="CMP"
 *           reentrant="False" schema="courses" primkey-field="name"
 * @ejb.pk class="java.lang.String"
 * @ejb.home generate="local" local-class="example.TeacherHome"
 * @ejb.interface generate="local" local-class="example.Teacher"
 *
 * @resin-ejb.entity-bean sql-table="one2one_teachers"
 */
abstract public class TeacherBean
  extends com.caucho.ejb.AbstractEntityBean {
  /**
   * @ejb.interface-method
   * @ejb.persistent-field
   * @ejb.pk-field
   */
  abstract public String getName();
  /**
   * @ejb.interface-method
   * @ejb.relation name="course-teacher"
   */
  abstract public Course getCourse();
}
</example>
</section>

  </body>
</document>
