2
I have a Cvariacaoto class that has a composite key (FK_T, FK_F, FK_F_VARIACAO). Two of these primary key fields (FK_F, FK_F_VARIACAO) are also foreign key to the Fvariacaoto table, in a Manytoone relationship
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "FK_F", referencedColumnName = "FK_F", nullable = false, insertable = false, updatable = false),
@JoinColumn(name = "FK_F_V", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false) })
@NotNull
private FVariacaoTO fVariacaoTO;
The class Fvariacaoto has two primary keys, which are being referenced, within a class Fvariacaopk.
I’m getting the following error: referencedColumnNames(FK_F, ID) by Cvariacaoto.fVariacaoTO not Mapped to a single Property
What normally causes this error? How can I resolve this relationship?
EDIT: Additional Information.
In the Fvariacaoto class, the key is @Embeddedid, as follows:
@EmbeddedId @AttributeOverrides({ @AttributeOverride(name = "fkF", column = @Column(name = "fkF", nullable = false)), @AttributeOverride(name = "id", column = @Column(name = "id", nullable = false)) }) @NotNull private FVariacaoPK fVariacaoPK;
And in the Fvariacaopk class, which has this ID indicated on @Embeddedid, it looks like this:
@Column(name = "FK_F", nullable = false) private int fkF;
@Column(name = "ID", nullable = false) private int id;
Your question is complicated to understand, it tries to put the error that is occurring and its cause, along with the classes with code formatting. This makes it difficult to help you. But this error occurs when you are setting the id of a map more than once. When subscribing to an id is required use @Attributeoverride(name="id",column=@Column(name="NOVA_ID"))
– Elyel Rubens da Rosa