title: Java Hibernate - assigning the right id for corresponding name in other table
body: <p>I am doing first step in Hibernate. I have a task I cannot solve.
  I have two tables and want to declare connection between them by finding the same String in two tables and assigning the corresponding id.
  Table 1 contains list of systems.</p>
  
  <pre><code>@Entity(name="system")
  public class SystemDsc {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private long id;
     private String name;
  
     public String getName() {
          return name;
      }
  
     public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>And Table 2 contains list of orders.</p>
  
  <pre><code>@Entity(name="system_contract")
  public class Order {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
      private long system_id;
      private String system;
  
      public long getSystem_id() {
          return system_id;
      }
  
      public void setSystem_id(long system_id) {
              this.system_id = system_id;
          }
  
      public String getSystem() {
          return system;
      }
  
      public void setSystem(String system) {
          this.system = system;
      }
  }
  </code></pre>
  
  <p>Multiple orders can have the same system value(for axample A01, B07 etc).
  List of systems with corresponding <strong><em>id</em></strong> values is stored in <strong>system</strong> table.
  While adding a new order, hibernate should look the same name of the system in <strong>system</strong> table and save corresponding to it id value in <strong><em>system_id</em></strong> column.</p>
  
  <p>Can it be done by @JoinColumn @OneToMany annotation?</p>