I have a situation.
@Entity
@Table(name = "customer")
public class Customer {
@EmbeddedId
private Id pk;
private String name;
private int age;
@OneToMany(mappedBy = "customer")
private List<Address> addresses;
@OneToMany
@JoinColumn(name = "company_id",referencedColumnName = "company_id")
private List<Account> accounts;
}
And here is my Id class
@Embeddable
public class Id {
@Column(name = "customer_id")
private int customerId;
@Column(name = "company_id")
private int companyId;
}
In My parent entity there is a composite key(customerId,companyId) but my child OneToMany entity accounts, i want to join it based on the one of the column from the embeded key that is companyId is there any way to do this. This is giving me the below error.
collection foreign key mapping has wrong number of columns: com.example.demo.entity.Customer.accounts type: component[companyId,customerId]