title: "Missing mapping for field..." at a OneToMany bidirectional relationship
body: <p>I'm really confused with the way a OneToMany biderectional relationship should be implemented in JPA. I'm getting oppossite answers the more I search.</p>
  
  <p>I'm dealing with an scenario where there are users ("Usuario" in spanish), and those users have records("Registro" in spanish). So a user has many records but a record has ony one user.</p>
  
  <p>So here's my code, first the user class:</p>
  
  <pre><code>@Entity
  @NamedQueries(@NamedQuery(name="Usuario.findAll", query="select o from Usuario o"))
  public class Usuario implements Serializable
  {
      ...
  
      @Id
      private String login;
  
      @OneToMany(mappedBy = "usuario", cascade = CascadeType.PERSIST)
      private List&lt;Registro&gt;avances;
  
      ...
  }
  </code></pre>
  
  <p>and the record class:</p>
  
  <pre><code>@Entity
  @NamedQueries(@NamedQuery(name="Registro.findAll", query="select o from Registro o"))
  public class Registro implements  Serializable
  {
      ...
  
      @ManyToOne(fetch=FetchType.EAGER, cascade = CascadeType.PERSIST)
      @JoinColumn(name = "usuario_login", referencedColumnName = "login")
      private Usuario usuario;
  
      ...
  }
  </code></pre>
  
  <p>But when I try to add a record to a user I get a long stack trace for this exception:</p>
  
  <pre><code>Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DescriptorException
  Exception Description: Missing mapping for field [USUARIO.login].
  Descriptor: RelationalDescriptor(com.teleconsulta.entities.Usuario --&gt; [DatabaseTable(USUARIO)])
      at oracle.toplink.essentials.exceptions.DescriptorException.missingMappingForField(DescriptorException.java:901)
      at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.extractValueFromObjectForField(ObjectBuilder.java:1635)
      ...
  </code></pre>
  
  <p>I have read different opinions saying that the MappedBy should be in the MANY side (records) and others that say that it should be in the ONE side (user). Is this the reason of the problem? how should the MappedBy be put in the many side?</p>