Pessoal,
Vejam, tenho uma classe que possui uma chave primária composta:
@Embeddable
public class PortBrasPK implements Serializable {
@ManyToOne
@JoinColumn(name="BRAS_FK")
private Bras bras;
@Column(name = "PORT_BRAS", length = 20, nullable = false)
private String port;
Classe que usa a classe acima como chave composta
@Entity
@Table(name = "PORT_BRAS")
public class PortBras implements Serializable {
@EmbeddedId()
private PortBrasPK portBrasPK;
@Column(name = "TOTAL_CUSTOMER", nullable = false)
private int totalCustomer;
@Column(name = "ACTIVE_CUSTOMER")
private int activeCustomer;
Até aqui td bem, porém na classe abaixo preciso criar um relacionamento com esta classe que possui a chave composta, fiz dessa forma:
@Entity
@Table(name = "DSLAM")
public class Dslam implements Serializable {
@Id
@Column(name="IP_DSLAM")
private String ipDslam;
@ManyToOne
@JoinColumns({
@JoinColumn(name="BRAS_FK", referencedColumnName="bras"),
@JoinColumn(name="PORT_BRAS", referencedColumnName="port")
})
private PortBras portBras;
@Column(name = "NAME", nullable = false, length = 255)
private String name;
@Column(name = "TYPE", nullable = false, length = 100)
private String type;
@Column(name = "TOTAL_CUSTOMER", nullable = false)
private int totalCustomer;
@Column(name = "ACTIVE_CUSTOMER", nullable = false)
private int activeCustomer;
Quando compilo, recebo a seguinte mensagem:
Exception Description: The @JoinColumns on the annotated element [private br.com.gvt.acct.entity.PortBras br.com.gvt.acct.entity.Dslam.portBras] from the entity class [class br.com.gvt.acct.entity.Dslam] is incomplete. When the source entity class uses a composite primary key, a @JoinColumn must be specified for each join column using the @JoinColumns. Both the name and the referenceColumnName elements must be specified in each such @JoinColumn.
Alguem sabe o que eu estou fazendo de errado?