1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Games.modeles;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
/**
*
* @author ROOT
*/
@Entity
public class Game implements Serializable {
private static final long serialVersionUID = 1L;
public enum Age {A3, A7, A12, A16, A18}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String gameName;
private String description;
private Age catAge;
// Gestion des relations
@OneToMany(fetch=FetchType.EAGER)
Collection<GameCategory> catList = new ArrayList<GameCategory>();
@ManyToMany(fetch=FetchType.EAGER)
Collection<Tag> tagList = new ArrayList<Tag>();
// @ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
// Collection<EOrder> ordersList = new ArrayList<EOrder>();
@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
Collection<CommentsAndMarks> commentAndMarksList = new ArrayList<CommentsAndMarks>();
@ManyToOne(fetch=FetchType.EAGER)
Distributor distributor;
@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
Collection<Photo> photoList = new ArrayList<Photo>();
public Game() {
}
public Game(String gameName,String Description, Age catAge, Distributor distributor) {
this.gameName = gameName;
this.description = Description;
this.catAge = catAge;
this.distributor = distributor;
}
public String getDescription() {
return description;
}
public Age getCatAge() {
return catAge;
}
public Collection<GameCategory> getCatList() {
return catList;
}
public Collection<CommentsAndMarks> getCommentAndMarksList() {
return commentAndMarksList;
}
public Distributor getDistributor() {
return distributor;
}
public String getGameName() {
return gameName;
}
public Collection<Tag> getTagList() {
return tagList;
}
public void setDescription(String Description) {
this.description = Description;
}
public void setCatAge(Age catAge) {
this.catAge = catAge;
}
public void setCatList(Collection<GameCategory> catList) {
this.catList = catList;
}
public void addCatToList(GameCategory cat) {
this.catList.add(cat);
}
public void setCommentAndMarksList(Collection<CommentsAndMarks> commentAndMarksList) {
this.commentAndMarksList = commentAndMarksList;
}
public void addCommentAndMarkToList(CommentsAndMarks com) {
this.commentAndMarksList.add(com);
}
public void setDistributor(Distributor distributor) {
this.distributor = distributor;
}
public void setGameName(String gameName) {
this.gameName = gameName;
}
public void setTagList(Collection<Tag> tagList) {
this.tagList = tagList;
}
public void addTagToList(Tag tag) {
this.tagList.add(tag);
}
public void setPhotoList(Collection<Photo> photoList) {
this.photoList = photoList;
}
public void addPhotoToList(Photo photo) {
this.photoList.add(photo);
}
public Collection<Photo> getPhotoList() {
return photoList;
}
// public Collection<EOrder> getOrdersList() {
// return ordersList;
// }
//
// public void setOrdersList(Collection<EOrder> ordersList) {
// this.ordersList = ordersList;
// }
//
// public void addOrderToList(EOrder order) {
// this.ordersList.add(order);
// }
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (int) id;
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Game)) {
return false;
}
Game other = (Game) object;
if (this.id != other.id) {
return false;
}
return true;
}
@Override
public String toString() {
return "Games.modeles.Game[id=" + id + "]";
}
} |
Partager