Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.springrest.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.DateSerializer; import java.io.Serializable; import java.util.Date; import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Temporal; /** * * @author ashok */ @Entity @Table(name = "employee") @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" }) public class Employee implements Serializable { private static final long serialVersionUID = -7788619177798333712L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private int id; @Column(name = "firstName") private String firstName; @Column(name = "lastName") private String lastName; @Column(name = "email") private String email; @Column(name = "telephone") private String telephone; @Column(name = "address") private String address; @Temporal(javax.persistence.TemporalType.DATE) @Column(name = "createdDate") private Date createdDate; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } @JsonSerialize(using = DateSerializer.class) public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } @Override public boolean equals(Object other) { if (!(other instanceof Employee)) { return false; } Employee that = (Employee) other; return this.getFirstName().equals(that.getFirstName()) && this.getLastName().equals(that.getLastName()) && this.getEmail().equals(that.getEmail()) && this.getTelephone().equals(that.getTelephone()) && this.getAddress().equals(that.getAddress()); } @Override public int hashCode() { int hash = 3; hash = 53 * hash + this.id; hash = 53 * hash + Objects.hashCode(this.firstName); hash = 53 * hash + Objects.hashCode(this.lastName); hash = 53 * hash + Objects.hashCode(this.email); hash = 53 * hash + Objects.hashCode(this.telephone); hash = 53 * hash + Objects.hashCode(this.address); hash = 53 * hash + Objects.hashCode(this.createdDate); return hash; } @Override public String toString() { return "id = " + id + ", firstName= " + firstName + ", lastName= " + lastName + ", email = " + email + ", telephone = " + telephone + ", address = " + address + ", createdDate = " + createdDate; } }