/******************************************************************************* * Copyright (c) 1998, 2015 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 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. * * 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 javax.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); } }