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
|
package ejb;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.jboss.ejb3.naming.client.java.javaURLContextFactory;
/* cette classe représente un document */
@Entity
public class Document implements Serializable{
// les variables correspondent aux colonnes de la table Document de la base de données
@Column(name = "nom", nullable = false)
private String nom; // le nom du document
@Column(name = "date_creation", nullable = false)
private java.util.Date date_creation; // la date de création du document
@Column(name = "emplacement", nullable = false)
private String emplacement; // l'emplacement du document
@Column(name = "modification", nullable = false)
@OneToMany (mappedBy = "document")
private java.util.Set<Modification> Modification; // la date de dernière modification
//@Column(name = "tag", nullable = false)
//private java.util.Set<Tag> tag; // la liste des tags représentant ce document
private static final long serialVersionUID = -728268157L;
@Column(name = "id", nullable = false)
private Long id; // l'identifiant obligatoire pour la table
@Column(name = "typeDocument", nullable = false)
private TypeDocument typeDocument; // le type du document : ex technique, commercial ..
// le constructeur qui est vide
public Document() {
super();
}
// redéfinition de la méthode ToString
public String toString() {
return "Document" + " nom=" + nom + " date_creation=" + date_creation
+ " emplacement=" + emplacement + " id=" + id;
}
// les getters et setters
public String getNom() {
return this.nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public java.util.Date getDate_creation() {
return this.date_creation;
}
public void setDate_creation(java.util.Date date_creation) {
this.date_creation = date_creation;
}
public String getEmplacement() {
return this.emplacement;
}
public void setEmplacement(String emplacement) {
this.emplacement = emplacement;
}
//@OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="document", targetEntity=Modification.class)
public Collection<Modification> getModification() {
if (Modification == null) {
Modification = new java.util.HashSet<Modification>();
}
return Modification;
}
public void setModification(java.util.Set<Modification> Modification) {
this.Modification = Modification;
}
public void addModification(Modification Modification) {
getModification().add(Modification);
}
public void removeModification(Modification Modification) {
getModification().remove(Modification);
}
//@ManyToMany(cascade=CascadeType.ALL, mappedBy="tags", targetEntity=Tag.class)
//@JoinTable(name="document_tag")
/*public java.util.Set<Tag> getTag() {
if (tag == null) {
tag = new java.util.HashSet<Tag>();
}
return tag;
}
public void setTag(java.util.Set<Tag> tag) {
this.tag = tag;
}
public void addTag(Tag tag) {
getTag().add(tag);
}
public void removeTag(Tag tag) {
getTag().remove(tag);
}
*/
@Id // tag définissant la clé primaire
@GeneratedValue(strategy=GenerationType.AUTO) // tag indiquant que la clé est auto générée
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
//@OneToOne(mappedBy="typeID")
public TypeDocument getTypeDocument() {
return this.typeDocument;
}
public void setTypeDocument(TypeDocument typeDocument) {
this.typeDocument = typeDocument;
}
} |