He models a triple bond. You need a map to use it. JPA 1.0 does not support Map, so if you want to use it, you need Hibernate because its Map suppport. This is something like
@Entity
public class A {
@ManyToMany
@org.hibernate.annotations.MapKeyManyToMany(
joinColumns=@JoinColumn(name="B_ID")
)
@JoinTable(
name="D",
joinColumns=@JoinColumn(name="A_ID"),
inverseJoinColumns=@JoinColumn(name="C_ID")
)
private Map<B, C> bAndC = new HashMap<B, C>();
}
, B, C. A C B.
@Entity
public class B {
@Id
private Integer id;
}
@Entity
public class C {
@Id
private Integer id;
}
, , ABC
public class AbC {
@ManyToOne
@JoinColumn(name="A_ID", insertable=false, updateable=false)
private A a;
@ManyToOne
@JoinColumn(name="B_ID", insertable=false, updateable=false)
private B b;
@ManyToOne
@JoinColumn(name="C_ID", insertable=false, updateable=false)
private C c;
@EmbeddedId
private A_b_C_i_D id;
@Embeddable
public static class A_b_C_i_D implements Serializable {
@Column(name="A_ID", updateable=false)
private Integer a_i_d;
@Column(name="B_ID", updateable=false)
private Integer b_i_d;
@Column(name="C_ID", updateable=false)
private Integer c_i_d;
public boolean equals(Object o) {
if(o == null)
return false;
if(!(o instanceof A_b_C_i_D))
return false;
A_b_C_i_D other = (A_b_C_i_D) o;
if(!(getA_i_d().equals(other.getA_i_d()))
return false;
if(!(getB_i_d().equals(other.getB_i_d()))
return false;
if(!(getC_i_d().equals(other.getC_i_d()))
return false;
return true;
}
public int hashcode() {
}
}
}
,