1.1 --- a/src/main/java/ru/indvdum/mywork/openjpa/model/Day.java Wed Aug 17 17:03:37 2011 +0300
1.2 +++ b/src/main/java/ru/indvdum/mywork/openjpa/model/Day.java Fri Aug 19 16:23:26 2011 +0300
1.3 @@ -1,6 +1,8 @@
1.4 package ru.indvdum.mywork.openjpa.model;
1.5
1.6 import java.sql.Time;
1.7 +import java.text.DateFormat;
1.8 +import java.text.SimpleDateFormat;
1.9 import java.util.Date;
1.10
1.11 import javax.persistence.Column;
1.12 @@ -22,7 +24,7 @@
1.13 private static final long serialVersionUID = 1471705339524132968L;
1.14
1.15 @Id
1.16 - @GeneratedValue(strategy = GenerationType.IDENTITY)
1.17 + @GeneratedValue
1.18 @Column(name = "ID", nullable = false)
1.19 private Integer id = null;
1.20
1.21 @@ -39,7 +41,7 @@
1.22 private Float hours = null;
1.23
1.24 public Day(){
1.25 -
1.26 +
1.27 }
1.28
1.29 @Override
1.30 @@ -51,7 +53,20 @@
1.31 if (!(obj instanceof Day))
1.32 return false;
1.33 final Day other = (Day) obj;
1.34 - return (this.id == other.id || (this.id != null && this.id.equals(other.id)));
1.35 + return (getId() == other.getId() || (getId() != null && getId().equals(other.getId())));
1.36 + }
1.37 +
1.38 + @Override
1.39 + public int hashCode() {
1.40 + if(getId() != null && getId() != 0)
1.41 + return getId().hashCode();
1.42 + else
1.43 + return super.hashCode();
1.44 + }
1.45 +
1.46 + @Override
1.47 + public String toString() {
1.48 + return getDateFormatter().format(getDay());
1.49 }
1.50
1.51 public Integer getId() {
1.52 @@ -93,4 +108,8 @@
1.53 public void setHours(Float hours) {
1.54 this.hours = hours;
1.55 }
1.56 +
1.57 + protected DateFormat getDateFormatter() {
1.58 + return new SimpleDateFormat("dd.MM.yyyy");
1.59 + }
1.60 }