| /* |
| * Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0, |
| * or the Eclipse Distribution License v. 1.0 which is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
| */ |
| |
| package org.eclipse.persistence.jpars.test.model.employee; |
| |
| import static jakarta.persistence.FetchType.LAZY; |
| import static jakarta.persistence.InheritanceType.JOINED; |
| |
| import jakarta.persistence.Basic; |
| import jakarta.persistence.Column; |
| import jakarta.persistence.DiscriminatorColumn; |
| import jakarta.persistence.Entity; |
| import jakarta.persistence.GeneratedValue; |
| import jakarta.persistence.Id; |
| import jakarta.persistence.Inheritance; |
| import jakarta.persistence.JoinColumn; |
| import jakarta.persistence.ManyToOne; |
| import jakarta.persistence.Table; |
| import jakarta.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; |
| } |
| } |