/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.ejb3.test.regression;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.Entity;
import java.util.ArrayList;
import java.util.Collection;

@Entity(name = "Branch")
@Inheritance(strategy = InheritanceType.JOINED)
public class Branch extends Contact
{

   private String city;
   private String country;
   private Collection<Employee> employees;

   public Branch()
   {
      this.employees = new ArrayList<Employee>();
   }

   public String getCity()
   {
      return this.city;
   }

   public void setCity(String city)
   {
      this.city = city;
   }

   public String getCountry()
   {
      return this.country;
   }

   public void setCountry(String country)
   {
      this.country = country;
   }

   public void addEmployee(Employee employee)
   {
      if (employees == null) employees = new ArrayList<Employee>();
      employees.add(employee);
      employee.setBranch(this);
   }

   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="branch")
   public Collection<Employee> getEmployees()
   {
      return this.employees;
   }

   public void setEmployees(Collection<Employee> employees)
   {
      this.employees = employees;
   }

}
