View Javadoc
1   package myorg.relex.many2many;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example of the inverse side of a many-to-many, uni-directional relationship
7    */
8   @Entity
9   @Table(name="RELATIONEX_INDIVIDUAL")
10  public class Individual {
11  	@Id @GeneratedValue
12  	private int id;
13  	
14  	@Column(length=32, nullable=false)
15  	private String name;
16  	
17  	protected Individual() {}
18  	public Individual(String name) {
19  		this.name = name;
20  	}
21  
22  	public int getId() { return id; }
23  
24  	public String getName() { return name; }
25  	public void setName(String name) {
26  		this.name = name;
27  	}
28  	
29  	@Override
30  	public int hashCode() {
31  		return name==null? 0 : name.hashCode();
32  	}
33  	
34  	@Override
35  	public boolean equals(Object obj) {
36  		try {
37  			if (this == obj)  return true;
38  			Individual rhs = (Individual) obj;
39  			if (name==null && rhs.name != null) { return false; }
40  			return name.equals(rhs.name);
41  		} catch (Exception ex) { return false; }
42  	}
43  }