Hello,
Suppose there is an many to many association between Class A and Class B.
Class A_B is their association class. Now i have following code with mapping annotation:
Class A
Code:
@Entity(access=AccessType.FIELD)
public class A implements Serializable {
@OneToMany( mappedBy="role_a")
private List<A_B> a_B = new ArrayList( );
@Id(generate=GeneratorType.IDENTITY)
public long id;
.....
Class B
Code:
@Entity(access=AccessType.FIELD)
public class B implements Serializable {
@OneToMany(mappedBy="role_b")
private A_B a_B = null;
@Id(generate=GeneratorType.IDENTITY)
public long id;
.....
Class A_B
Code:
@Entity(access=AccessType.FIELD)
public class A_B implements Serializable {
@ManyToOne(cascade=CascadeType.All)
private A role_a = new AA();
@ManyToOne(cascade=CascadeType.All)
private B role_b = new B();
.......
How can i make the fields "role_b" and "role_a" in Class A_B to be composite primary key????
any help would be appreciated