title: Hibernate Relationships Annotations
body: <p>Using @ManyToOne and @OneToMany how do I define relationships between the following tables. I'm new to hibernate and am unsure if my work is correct. Do I need two separate relationship annotations for the two foreign keys in the route table?</p>
  
  <p>MySQL:</p>
  
  <pre><code>CREATE TABLE BusStop ( 
  ID int NOT NULL,
  Description varchar(40) NOT NULL,
  PRIMARY KEY (ID))
  Engine=InnoDB;
  
  CREATE TABLE Route ( 
  Route_Number int NOT NULL,
  Destination int NOT NULL
  Frequency int NOT NULL,
  Start int NOT NULL,
  PRIMARY KEY (Route_Number),
  FOREIGN KEY (Destination) 
  REFERENCES BusStop(ID),
  FOREIGN KEY (Start) REFERENCES BusStop(ID) 
  Engine=InnoDB
  </code></pre>
  
  <p>BusStop.java:</p>
  
  <pre><code>public class BusStop {
  
  public static final String SELECT_ALL = "BusStop.selectAll";
  
  @Id
  @Column(name = "id")
  private int id;
  
  @Column(name = "description")
  private String description;
  
  public BusStop(){}
  public int getId(){
      return id;
  }
  
  public void setId(int id){
      this.id = id;
  }
  
  public void setDescription( String description ) {
      this.description = description;
   }
  
  public String getDescription() {
      return description;
   }
  
  @OneToMany(mappedBy="startRef")
  private Set&lt;Route&gt; startStop;
  
  @OneToMany(mappedBy="destRef")
  private Set&lt;Route&gt; destStop;
  
  }
  </code></pre>
  
  <p>Route.java</p>
  
  <pre><code>@Table(name = "route")
  public class Route {
  public static final String SELECT_ALL = "Route.selectAll";
  
  @Id
  @Column(name = "route_number")
  private int route_number;
  
  @Column(name = "destination")
  private int destination;
  
  @Column(name = "frequency")
  private int frequency;
  
  @Column(name = "start")
  private int start;
  
  private Set&lt;Operator&gt; operators = new HashSet&lt;Operator&gt;();
  
  public Route(){}
  
  // getters &amp; setters
  
  @ManyToOne
  @JoinColumn(name="start")
  private BusStop startRef;
  
  @ManyToOne
  @JoinColumn(name="destination")
  private BusStop destRef;
  </code></pre>
  
  <p>Thank you for your help.</p>