I am trying to define JPA layer over a db I cannot redesign. That layer contains a OneToMany relationship where the Many part has a foreign key consisting of the same 2 fields that the one part has as primary key.
@Embeddable
public class FooKey implements Serializable {
@Column(name="foo_id")
private String id;
private String secondaryId;
}
public class Foo {
@EmbeddedId
private FooKey id;
(...)
}
public class Bar {
@Id
private Long id;
(...)
//@Embedded FooKey fooKey;
@ManyToOne
private Foo foo;
}
How can I solve this? I am getting the error @Column(s) not allowed on a @ManyToOne property