title: Hibernate and JPA: how to make a foreign key constraint on a String
body: <p>I am using Hibernate and JPA.  If I have two simple entities:</p>
  
  <pre><code>@Entity
  @Table(name = "container")
  public class Container {
    @Id
    @Column(name="guid")
    private String guid;
  }
  
  @Entity
  @Table(name="item")
  public class Item {
    @Id
    @Column(name="guid")
    private String guid;
  
    @Column(name="container_guid")
    private String containerGuid;
  }
  </code></pre>
  
  <p>and I want to insure that inserting an Item fails if the referenced Container does not exist.  I would prefer not to have a Container object populated inside the item object (ManyToOne), how would I do this if it is possible to do?</p>