View Javadoc
1   package ejava.jpa.examples.tuning.bo;
2   
3   import java.io.Serializable;
4   import java.util.Date;
5   
6   public class MoviePK implements Serializable {
7   	private static final long serialVersionUID = -4411388426942024278L;
8   	private String title;
9   	private Date releaseDate;
10  
11  	protected MoviePK() {}
12  	public MoviePK(String title, Date releaseDate) {
13  		this.title = title;
14  		this.releaseDate = releaseDate;
15  	}
16  	
17  	public String getTitle() { return title; }
18  	public Date getReleaseDate() { return releaseDate; }
19  	
20  	@Override
21  	public int hashCode() {
22  		return (title==null?0:title.hashCode()) +
23  				(releaseDate==null?0:releaseDate.hashCode());
24  	}
25  	
26  	@Override
27  	public boolean equals(Object obj) {
28  		try {
29  			if (this == obj) { return true; }
30  			if (obj == null) { return false; }
31  			MoviePK rhs = (MoviePK)obj;
32  			if (title != null && releaseDate != null) {
33  				return title.equals(rhs.title) && releaseDate.equals(rhs.releaseDate);
34  			}
35  			if (title==null && rhs.title != null) { return false; }
36  			if (releaseDate==null && rhs.releaseDate != null) { return false; }
37  			return true;
38  		} catch (Exception ex) { return false; }
39  	}
40  	
41  }