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.entity;
023:
024: import java.util.Set;
025: import javax.persistence.CascadeType;
026: import javax.persistence.Entity;
027: import javax.persistence.FetchType;
028: import javax.persistence.GeneratedValue;
029: import javax.persistence.GenerationType;
030: import javax.persistence.Id;
031: import javax.persistence.JoinColumn;
032: import javax.persistence.ManyToMany;
033: import javax.persistence.OneToMany;
034: import javax.persistence.OneToOne;
035:
036: /**
037: * Company customer
038: *
039: * @author Emmanuel Bernard
040: */
041: @Entity
042: public class Customer implements java.io.Serializable {
043: Long id;
044: String name;
045: Set<Ticket> tickets;
046: Set<Flight> flights;
047: Address address;
048:
049: public Customer() {
050: }
051:
052: @Id
053: @GeneratedValue(strategy=GenerationType.AUTO)
054: public Long getId() {
055: return id;
056: }
057:
058: public String getName() {
059: return name;
060: }
061:
062: public void setId(Long long1) {
063: id = long1;
064: }
065:
066: public void setName(String string) {
067: name = string;
068: }
069:
070: @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="customer")
071: public Set<Ticket> getTickets() {
072: return tickets;
073: }
074:
075: public void setTickets(Set<Ticket> tickets) {
076: this .tickets = tickets;
077: }
078:
079: @OneToOne(cascade={CascadeType.ALL})
080: @JoinColumn(name="ADDRESS_ID")
081: public Address getAddress() {
082: return address;
083: }
084:
085: public void setAddress(Address address) {
086: this .address = address;
087: }
088:
089: @ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE},fetch=FetchType.EAGER,mappedBy="customers")
090: public Set<Flight> getFlights() {
091: return flights;
092: }
093:
094: public void setFlights(Set<Flight> flights) {
095: this .flights = flights;
096: }
097:
098: /*
099: @OneToMany(cascade = CascadeType.ALL,
100: targetEntity = "org.hibernate.test.metadata.Discount")
101: @JoinColumn(name = "CUSTOMER_ID")
102: public Collection getDiscountTickets()
103: {
104: return discountTickets;
105: }
106:
107: public void setDiscountTickets(Collection collection)
108: {
109: discountTickets = collection;
110: }
111: */
112: }
|