title: hibernate one to many single direction
body: <p>I'm trying to make some hibernate stuff and create sql scripts automatically based on the hibernate annotations. Here is what I have:  </p>
  
  <p>Schedule class:</p>
  
  <pre><code>@Entity
  @Table(name = ScheduleTableConsts.TABLE_NAME)
  public class Schedule implements Serializable {
  
  @Id
  @Column(name = ScheduleTableConsts.ID_COLUMN)
  @GeneratedValue(strategy = GenerationType.AUTO)
  private int id;
  
  @OneToMany(cascade=CascadeType.ALL)
  @JoinColumn(name = ScheduleSlotTableConsts.ID_COLUMN)
  private List&lt;ScheduleSlot&gt; scheduleSlots;
  
  @OneToMany(cascade=CascadeType.ALL)
  @JoinColumn(name = LessonTableConsts.ID_COLUMN)
  private List&lt;Lesson&gt; lessons;  
  
  Constructors, getters, setters...
  </code></pre>
  
  <p>ScheduleSlot class:  </p>
  
  <pre><code>@Entity
  @Table(name = ScheduleSlotTableConsts.TABLE_NAME,
         uniqueConstraints = {@UniqueConstraint(columnNames = {TimeSlotTableConsts.ID_COLUMN,
                                                               PlaceSlotTableConsts.ID_COLUMN})})
  public class ScheduleSlot implements Serializable {
  @Id
  @Column(name = ScheduleSlotTableConsts.ID_COLUMN)
  @GeneratedValue(strategy = GenerationType.AUTO)
  private int id;
  
  @OneToOne
  @JoinColumn(name = TimeSlotTableConsts.ID_COLUMN)
  private TimeSlot timeSlot;
  
  @OneToOne
  @JoinColumn(name = PlaceSlotTableConsts.ID_COLUMN)
  private PlaceSlot placeSlot;  
  
  Constructors, getters, setters...  
  </code></pre>
  
  <p>Lesson class: </p>
  
  <pre><code>@Entity
  @Table(name = LessonTableConsts.TABLE_NAME)
  public class Lesson implements Serializable {
  
  @Id
  @Column(name = LessonTableConsts.ID_COLUMN)
  @GeneratedValue(strategy = GenerationType.AUTO)
  private int            id;
  
  @OneToMany(fetch = FetchType.LAZY)
  private Set&lt;Professor&gt; professors;
  
  @OneToMany(fetch = FetchType.LAZY)
  private Set&lt;Course&gt;    courses;
  
  @OneToMany(fetch = FetchType.LAZY)
  private Set&lt;Group&gt;     groups;
  
  @Column(name = LessonTableConsts.LAB_COLUMN)
  private boolean        lab;  
  
  Constructors, getters, setters...
  </code></pre>
  
  <p>What I'm trying to achieve is to let schedule know about it's slots and lessons and not to let slots and lessons know about the schedule they are belong to. The code above seems to be ok, but when I'm trying to generate sql script (using maven and hibernate3-maven-plugin for that purposes) and run it the following happens:  </p>
  
  <ol>
  <li>It creates a SCHEDULE table with no pointers to SCHEDULESLOT or LESSON tables;</li>
  <li>It creates SCHEDULESLOT and LESSON tables with no pointers to SCHEDULE table. </li>
  </ol>
  
  <p>Could somebody, please, tell me what I am doing wrong?  </p>
  
  <p>Thank in advance!</p>