src/main/java/ru/indvdum/mywork/openjpa/model/WorkId.java
author indvdum
Wed, 17 Aug 2011 17:03:37 +0300
changeset 8 56338d6d58c2
parent 7 aaae4f8055f4
permissions -rw-r--r--
Work-table JPA model
     1 package ru.indvdum.mywork.openjpa.model;
     2 
     3 import javax.persistence.Embeddable;
     4 
     5 /**
     6  * @author indvdum
     7  * 17.08.2011 15:00:35
     8  *
     9  */
    10 @Embeddable
    11 public class WorkId{
    12 	
    13 	public Integer dayId;
    14 	public Integer taskId;
    15 	
    16 	@Override
    17 	public boolean equals(Object obj) {
    18 		if (this == obj)
    19 			return true;
    20 		if (obj == null)
    21 			return false;
    22 		if (!(obj instanceof WorkId))
    23 			return false;
    24 		final WorkId other = (WorkId) obj;
    25 		return (
    26 				this.dayId == other.dayId 
    27 				&& this.taskId == other.taskId 
    28 				|| (
    29 						this.dayId != null 
    30 						&& this.dayId.equals(other.dayId) 
    31 						&& this.taskId != null 
    32 						&& this.taskId.equals(other.taskId)
    33 						)
    34 				);
    35 	}
    36 
    37 	@Override
    38 	public int hashCode() {
    39 		return dayId ^ taskId;
    40 	}
    41 
    42 }