| /* |
| * Copyright (c) 1998, 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 |
| */ |
| |
| // Contributors: |
| // Oracle - initial API and implementation from Oracle TopLink |
| |
| package org.eclipse.persistence.testing.models.jpa.xml.advanced.compositepk; |
| |
| import java.util.Vector; |
| import java.util.Collection; |
| |
| import jakarta.persistence.Id; |
| |
| public class Department { |
| private String name; |
| private String role; |
| private String location; |
| private Collection<Scientist> scientists; |
| |
| public Department() { |
| scientists = new Vector<Scientist>(); |
| } |
| |
| @Id |
| public String getName() { |
| return name; |
| } |
| |
| public void setName(String name) { |
| this.name = name; |
| } |
| |
| @Id |
| public String getRole() { |
| return role; |
| } |
| |
| public void setRole(String role) { |
| this.role = role; |
| } |
| |
| @Id |
| public String getLocation() { |
| return location; |
| } |
| |
| public void setLocation(String location) { |
| this.location = location; |
| } |
| |
| //@OneToMany(fetch=EAGER, mappedBy="department") |
| //@OrderBy // will default to Scientists composite pk. |
| public Collection<Scientist> getScientists() { |
| return scientists; |
| } |
| |
| public void setScientists(Collection<Scientist> scientists) { |
| this.scientists = scientists; |
| } |
| |
| public Scientist addScientist(Scientist scientist) { |
| scientists.add(scientist); |
| scientist.setDepartment(this); |
| return scientist; |
| } |
| |
| public Scientist removeScientist(Scientist scientist) { |
| scientists.remove(scientist); |
| scientist.setDepartment(null); |
| return scientist; |
| } |
| |
| public DepartmentPK getPK() { |
| return new DepartmentPK(name, role, location); |
| } |
| } |