src/main/java/ru/indvdum/mywork/openjpa/model/Work.java
author indvdum
Wed, 17 Aug 2011 17:03:37 +0300
changeset 8 56338d6d58c2
parent 7 aaae4f8055f4
child 9 6a02cfcc7460
permissions -rw-r--r--
Work-table JPA model
     1 package ru.indvdum.mywork.openjpa.model;
     2 
     3 import javax.persistence.Column;
     4 import javax.persistence.EmbeddedId;
     5 import javax.persistence.Entity;
     6 import javax.persistence.FetchType;
     7 import javax.persistence.ManyToOne;
     8 import javax.persistence.MapsId;
     9 import javax.persistence.Table;
    10 
    11 /**
    12  * @author indvdum
    13  * 16.08.2011 13:55:51
    14  *
    15  */
    16 @Entity
    17 @Table(name = "WORK")
    18 public class Work implements IDatabaseObject {
    19 
    20 	private static final long serialVersionUID = 7138260708537798813L;
    21 	
    22 	@EmbeddedId
    23 	WorkId id;
    24 	
    25 	@Column(name = "HOURS")
    26 	private Float hours = null;
    27 	
    28 	@Column(name = "RESULT")
    29 	private String result = null;
    30 	
    31 	@MapsId("dayId")
    32 	@ManyToOne(fetch = FetchType.EAGER)
    33 	private Day day = null;
    34 	
    35 	@MapsId("taskId")
    36 	@ManyToOne(fetch = FetchType.EAGER)
    37 	private Task task = null;
    38 	
    39 	public Work(){
    40 		
    41 	}
    42 
    43 	@Override
    44 	public boolean equals(Object obj) {
    45 		if (this == obj)
    46 			return true;
    47 		if (obj == null)
    48 			return false;
    49 		if (!(obj instanceof Work))
    50 			return false;
    51 		final Work other = (Work) obj;
    52 		return (
    53 				this.day == other.day 
    54 				&& this.task == other.task 
    55 				|| (
    56 						this.day != null 
    57 						&& this.day.equals(other.day) 
    58 						&& this.task != null 
    59 						&& this.task.equals(other.task)
    60 						)
    61 				);
    62 	}
    63 
    64 	public Float getHours() {
    65 		return hours;
    66 	}
    67 
    68 	public void setHours(Float hours) {
    69 		this.hours = hours;
    70 	}
    71 
    72 	public String getResult() {
    73 		return result;
    74 	}
    75 
    76 	public void setResult(String result) {
    77 		this.result = result;
    78 	}
    79 
    80 	public Day getDay() {
    81 		return day;
    82 	}
    83 
    84 	public void setDay(Day day) {
    85 		this.day = day;
    86 	}
    87 
    88 	public Task getTask() {
    89 		return task;
    90 	}
    91 
    92 	public void setTask(Task task) {
    93 		this.task = task;
    94 	}
    95 
    96 	public String getDayName() {
    97 		return getDay().getDay().toString();
    98 	}
    99 	
   100 	public String getTaskName() {
   101 		return getTask().getName();
   102 	}
   103 
   104 }