001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb3.test.manytomany;
023:
024: import javax.persistence.CascadeType;
025: import javax.persistence.Entity;
026: import javax.persistence.FetchType;
027: import javax.persistence.GeneratedValue;
028: import javax.persistence.GenerationType;
029: import javax.persistence.Id;
030: import javax.persistence.JoinColumn;
031: import javax.persistence.Id;
032: import javax.persistence.OneToOne;
033: import javax.persistence.ManyToMany;
034: import javax.persistence.OneToMany;
035: import javax.persistence.OneToOne;
036: import javax.persistence.OneToMany;
037: import javax.persistence.CascadeType;
038: import javax.persistence.FetchType;
039: import javax.persistence.GeneratedValue;
040: import javax.persistence.GenerationType;
041: import javax.persistence.Entity;
042: import java.util.Set;
043:
044: /**
045: * Company customer
046: *
047: * @author Emmanuel Bernard
048: */
049: @Entity
050: public class Customer implements java.io.Serializable {
051: Long id;
052: String name;
053: Set<Ticket> tickets;
054: Set<Flight> flights;
055: Address address;
056:
057: public Customer() {
058: }
059:
060: @Id
061: @GeneratedValue(strategy=GenerationType.IDENTITY)
062: public Long getId() {
063: return id;
064: }
065:
066: public String getName() {
067: return name;
068: }
069:
070: public void setId(Long long1) {
071: id = long1;
072: }
073:
074: public void setName(String string) {
075: name = string;
076: }
077:
078: @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="customer")
079: public Set<Ticket> getTickets() {
080: return tickets;
081: }
082:
083: public void setTickets(Set<Ticket> tickets) {
084: this .tickets = tickets;
085: }
086:
087: @OneToOne(cascade={CascadeType.ALL})
088: @JoinColumn(name="ADDRESS_ID")
089: public Address getAddress() {
090: return address;
091: }
092:
093: public void setAddress(Address address) {
094: this .address = address;
095: }
096:
097: @ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.EAGER,mappedBy="customers")
098: public Set<Flight> getFlights() {
099: return flights;
100: }
101:
102: public void setFlights(Set<Flight> flights) {
103: this.flights = flights;
104: }
105:
106: }
|