KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > manytomany > Store


1 //$Id: Store.java,v 1.2 2005/06/23 14:10:56 epbernard Exp $
2
package org.hibernate.test.annotations.manytomany;
3
4 import java.util.Set JavaDoc;
5 import javax.persistence.CascadeType;
6 import javax.persistence.Entity;
7 import javax.persistence.GeneratorType;
8 import javax.persistence.Id;
9 import javax.persistence.JoinColumn;
10 import javax.persistence.JoinTable;
11 import javax.persistence.ManyToMany;
12 import javax.persistence.Table;
13
14 /**
15  * @author Emmanuel Bernard
16  */

17 @Entity
18 public class Store {
19     private Integer JavaDoc id;
20     private String JavaDoc name;
21     private Set JavaDoc<KnownClient> customers;
22     private Set JavaDoc<Supplier> suppliers;
23
24     @ManyToMany(cascade = CascadeType.PERSIST)
25     public Set JavaDoc<City> getImplantedIn() {
26         return implantedIn;
27     }
28
29     public void setImplantedIn(Set JavaDoc<City> implantedIn) {
30         this.implantedIn = implantedIn;
31     }
32
33     private Set JavaDoc<City> implantedIn;
34
35     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
36     @JoinTable(
37             table = @Table(name="StoreSupplier"),
38             joinColumns = @JoinColumn(name="store"),
39             inverseJoinColumns = @JoinColumn(name="supplier")
40     )
41     public Set JavaDoc<Supplier> getSuppliers() {
42         return suppliers;
43     }
44
45     public void setSuppliers(Set JavaDoc<Supplier> suppliers) {
46         this.suppliers = suppliers;
47     }
48
49     @Id(generate = GeneratorType.AUTO)
50     public Integer JavaDoc getId() {
51         return id;
52     }
53
54     public void setId(Integer JavaDoc id) {
55         this.id = id;
56     }
57
58     public String JavaDoc getName() {
59         return name;
60     }
61
62     public void setName(String JavaDoc name) {
63         this.name = name;
64     }
65
66     @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
67     public Set JavaDoc<KnownClient> getCustomers() {
68         return customers;
69     }
70
71     public void setCustomers(Set JavaDoc<KnownClient> customers) {
72         this.customers = customers;
73     }
74 }
75
Popular Tags