/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
//$Id: Customer.java,v 1.1.2.6 2005/09/27 01:49:19 starksm Exp $
package org.jboss.ejb3.test.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.JoinColumn;
import javax.persistence.GeneratorType;

import java.util.Set;

/**
 * Company customer
 *
 * @author Emmanuel Bernard
 */
@Entity
public class Customer implements java.io.Serializable
{
   Long id;
   String name;
   Set<Ticket> tickets;
   Set<Flight> flights;
   Address address;

   public
   Customer()
   {
   }

   @Id(generate = GeneratorType.IDENTITY)
           public
   Long getId()
   {
      return id;
   }

   public
   String getName()
   {
      return name;
   }

   public
   void setId(Long long1)
   {
      id = long1;
   }

   public
   void setName(String string)
   {
      name = string;
   }

   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="customer")
   public Set<Ticket> getTickets()
   {
      return tickets;
   }

   public void setTickets(Set<Ticket> tickets)
   {
      this.tickets = tickets;
   }

   @OneToOne(cascade = {CascadeType.ALL})
           @JoinColumn(name = "ADDRESS_ID")
           public Address getAddress()
   {
      return address;
   }

   public void setAddress(Address address)
   {
      this.address = address;
   }

   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, mappedBy="customers")
   public Set<Flight> getFlights()
   {
      return flights;
   }

   public void setFlights(Set<Flight> flights)
   {
      this.flights = flights;
   }


   /*
   @OneToMany(cascade = CascadeType.ALL,
              targetEntity = "org.hibernate.test.metadata.Discount")
   @JoinColumn(name = "CUSTOMER_ID")
   public Collection getDiscountTickets()
   {
      return discountTickets;
   }

   public void setDiscountTickets(Collection collection)
   {
      discountTickets = collection;
   }
   */
}

