View Javadoc

1   package net.sf.r4h.model;
2   
3   import javax.persistence.GeneratedValue;
4   import javax.persistence.Id;
5   import javax.persistence.MappedSuperclass;
6   
7   @MappedSuperclass
8   public class BaseEntity {
9   	@Id
10  	@GeneratedValue
11  	private int id;
12  
13  	private String name;
14  
15  	public int getId() {
16  		return id;
17  	}
18  
19  	public void setId(int id) {
20  		this.id = id;
21  	}
22  
23  	public String getName() {
24  		return name;
25  	}
26  
27  	public void setName(String name) {
28  		this.name = name;
29  	}
30  
31  	@Override
32  	public int hashCode() {
33  		final int prime = 31;
34  		int result = 1;
35  		result = prime * result + id;
36  		return result;
37  	}
38  
39  	@Override
40  	public boolean equals(Object obj) {
41  		if (this == obj) {
42  			return true;
43  		}
44  		if (obj == null) {
45  			return false;
46  		}
47  		if (!(obj instanceof BaseEntity)) {
48  			return false;
49  		}
50  		BaseEntity other = (BaseEntity) obj;
51  		if (id != other.id) {
52  			return false;
53  		}
54  		return true;
55  	}
56  
57  	@Override
58  	public String toString() {
59  		return getClass() + ", id=" + id + ", name=" + name;
60  	}
61  
62  }