Reputation: 1018
I need map at JPA something like this:
How I can map two relationships between two "tables", one of them is primary key and one to one (newClient in advance) and in the other side, a one to many that aint PK?
I tried something like this but it fails.
public class Recommendation implements Serializable {
@Id @OneToOne
@Column(name="...")
private Client newClient;
@ManyToOne
@Column(name="...")
private Client oldFella;
@Column(name="...")
private Boolean wasUsedToGenerateBond;
...
}
Thanks!
Upvotes: 0
Views: 1021
Reputation:
it is possible to have multiple ManyToMany relationships between two entities. Each relationship would have its own join table. The default name of the join table may be the same, so you would need to specify the @JoinTable's name.
possible answer here
JPA Problems mapping relationships
more information
Hibernate 4.2, bidirectional @OneToOne and @Id
Upvotes: 1
Reputation: 4623
Like this:
@Id @OneToOne
@JoinColumn(name="id_client1")
private Client newClient;
@ManyToOne
@JoinColumn(name="id_client2")
private Client oldFella;
Upvotes: 0