1 package myorg.relex.many2many;
2
3 import java.util.HashSet;
4 import java.util.Set;
5 import javax.persistence.*;
6
7
8
9 @Entity
10 @Table(name="RELATIONEX_GROUP")
11 public class Group {
12 @Id @GeneratedValue
13 private int id;
14
15 @ManyToMany
16 @JoinTable(name="RELATIONEX_GROUP_MEMBER",
17 joinColumns=@JoinColumn(name="GROUP_ID"),
18 inverseJoinColumns=@JoinColumn(name="MEMBER_ID"))
19 Set<Individual> members;
20
21 @Column(length=32, nullable=false)
22 private String name;
23
24 protected Group() {}
25 public Group(String name) {
26 this.name = name;
27 }
28
29 public int getId() { return id; }
30 public Set<Individual> getMembers() {
31 if (members == null) {
32 members = new HashSet<Individual>();
33 }
34 return members;
35 }
36
37 public String getName() { return name; }
38 public void setName(String name) {
39 this.name = name;
40 }
41 }