/******************************************************************************* * Copyright (c) 2011, 2015 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 * which accompanies this distribution. * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. * ******************************************************************************/ package org.eclipse.persistence.jpars.test.model.employee; import static javax.persistence.FetchType.LAZY; import static javax.persistence.InheritanceType.JOINED; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.DiscriminatorColumn; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Inheritance; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Version; @Entity @Table(name = "JPARS_PROJECT") @Inheritance(strategy = JOINED) @DiscriminatorColumn(name = "PROJ_TYPE") public abstract class Project { @Id @Column(name = "PROJ_ID") @GeneratedValue private int id; @Basic @Column(name = "PROJ_NAME") private String name; @Basic @Column(name = "DESCRIP") private String description; @Version private Long version; @ManyToOne(fetch = LAZY) @JoinColumn(name = "LEADER_ID") private Employee teamLeader; public Project() { } public String getDescription() { return this.description; } public void setDescription(String descrip) { this.description = descrip; } public int getId() { return this.id; } public void setId(int projId) { this.id = projId; } public String getName() { return this.name; } public void setName(String projName) { this.name = projName; } public Long getVersion() { return version; } public void setVersion(Long version) { this.version = version; } public Employee getTeamLeader() { return this.teamLeader; } public void setTeamLeader(Employee employee) { this.teamLeader = employee; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + id; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((version == null) ? 0 : version.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Project other = (Project) obj; if (description == null) { if (other.description != null) return false; } else if (!description.equals(other.description)) return false; if (id != other.id) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (version == null) { if (other.version != null) return false; } else if (!version.equals(other.version)) return false; return true; } @Override public String toString() { return "id=" + id + ", name=" + name; } }