title: JPA - wrong number of column. should be 2
body: <blockquote>
    <p>A Foreign key refering br.com.copagaz.inova.mobile.persistencia.entidade.viagem.nf.NFeProtocolo from br.com.copagaz.inova.mobile.persistencia.entidade.viagem.nf.NfCabeca has the wrong number of column. should be 2</p>
  </blockquote>
  
  <p>My problem is in one column reference, if i remove @ManyToOne and @JoinColumn(name = "protocolo"), the system works but the selects does not.
  i tried to use hibernate.hbm2ddl.auto to auto create the FKs but with no success. 
  I think the nfe_operacao use a composed PK, and nf_cabeca reference's ii, but did not work.</p>
  
  <p>Any one could help?</p>
  
  <pre><code>@Entity
  @Table(name = "nf_cabeca", schema = "mobile", uniqueConstraints = 
      {@UniqueConstraint(columnNames = 
          {"NUMERO_FILIAL","serie_nota","numero_nota"})})
  public class NfCabeca implements java.io.Serializable {
  
      private static final long serialVersionUID = -921687831233770627L;
  
      @Id
      @SequenceGenerator(name = "nf_cabeca_sequencial_seq", sequenceName = "nf_cabeca_sequencial_seq", schema = "mobile", allocationSize = 1, initialValue = 1)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "nf_cabeca_sequencial_seq")
      @Column(name = "sequencial", insertable = false, updatable = false)
      private long sequencial;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "data_hora", nullable = false, length = 29)
      private Date dataHora;
  
      @Column(name = "valor_total", nullable = false, precision = 17, scale = 17)
      private Double valorTotal;
  
      @Column(name = "cancelada")
      private Integer cancelada;
  
      @Temporal(TemporalType.DATE)
      @Column(name = "data_vencimento", length = 13)
      private Date dataVencimento;
  
      @Column(name = "boleto", length = 17)
      private String boleto;
  
      @ManyToOne
      @JoinColumn(name = "protocolo")
      private NFeProtocolo protocolo;
  
      @Column(name = "chave")
      private String chave;
  
      @Column(name = "status_nf")
      private Integer statusNf;
  
      @Column(name = "status_danfe")
      private Integer statusDanfe;
  
      @Column(name = "modelo", length = 3)
      private String modelo;
  
      @Column(name = "reconciliada")
      private boolean reconciliada = false;
  
      @OneToMany(mappedBy = "nfCabeca", cascade = CascadeType.MERGE)
      private List&lt;NfObservacao&gt; nfObservacao;
  
      @OneToMany(mappedBy = "nfCabeca", cascade = CascadeType.ALL)
      private List&lt;NfItens&gt; nfItens;
  
      @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
      @JoinColumn(name = "nf_cabeca")
      private List&lt;NFeProtocolo&gt; protocolos = new ArrayList&lt;NFeProtocolo&gt;();
  
  }
  </code></pre>
  
  <p>This references this table:</p>
  
  <pre><code>@Entity
  @IdClass(NFeProtocoloId.class)
  @Table(name = "nfe_protocolo", schema = "mobile")
  public class NFeProtocolo implements Serializable {
  
      private static final long serialVersionUID = 2092981840170296102L;
  
      @Id
      @Column(name = "nf_cabeca", length = 100, insertable = false, updatable = false)
      private long nf_cabeca_id;
  
      @Id
      @Column(name = "protocolo", length = 100)
      private String protocolo;
  
      @Column(name = "operacao", length = 15, nullable = false)
      @Enumerated(EnumType.STRING)
      private NFeProtocoloOperacao operacao;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "data_hora", length = 29, nullable = false)
      private Date dataHora;
  
      @Column(name = "status", length = 10)
      private String status;
  }
  </code></pre>