/******************************************************************************* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 2013,2014 by Peter Pilgrim, Addiscombe, Surrey, XeNoNiQUe UK * * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU GPL v3.0 * which accompanies this distribution, and is available at: * http://www.gnu.org/licenses/gpl-3.0.txt * * Developers: * Peter Pilgrim -- design, development and implementation * -- Blog: http://www.xenonique.co.uk/blog/ * -- Twitter: @peter_pilgrim * * Contributors: * *******************************************************************************/ package je7hb.jpa.advanced.criteria; import javax.persistence.*; import java.math.BigDecimal; /** * The type Employee * * @author Peter Pilgrim */ @Entity public class Employee { @Id @Column(name = "EMP_ID") private int id; @Column(name = "FIRST_NAME") private String firstName; @Column(name = "LAST_NAME") private String lastName; private BigDecimal salary; @Column(name = "DAILY_RATE") private BigDecimal dailyRate; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "TAX_CODE_ID") private TaxCode taxCode; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "REGION_ID") private Region region; public Employee() { } public Employee(int id, String firstName, String lastName) { this.id = id; this.firstName = firstName; this.lastName = lastName; } public Employee(int id, String firstName, String lastName, TaxCode taxCode, Region region) { this.id = id; this.firstName = firstName; this.lastName = lastName; this.taxCode = taxCode; this.region = region; } 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 TaxCode getTaxCode() { return taxCode; } public void setTaxCode(TaxCode taxCode) { this.taxCode = taxCode; } public Region getRegion() { return region; } public void setRegion(Region region) { this.region = region; } public BigDecimal getSalary() { return salary; } public void setSalary(BigDecimal salary) { this.salary = salary; } public BigDecimal getDailyRate() { return dailyRate; } public void setDailyRate(BigDecimal dailyRate) { this.dailyRate = dailyRate; } @Override public String toString() { return "Employee{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", salary=" + salary + ", dailyRate=" + dailyRate + ", taxCode=" + taxCode + ", region=" + region + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Employee)) return false; Employee employee = (Employee) o; if (id != employee.id) return false; return true; } @Override public int hashCode() { return id; } }