Bonjour je voudrais s'avoir comment je peut faire pour recuprer le nombre d'article pour chaque catégorie ainsi que le nom de la catégorie pour les entity suivante en sachant que le lien entre article et catégorie est le champs catégorie dans le champs article

article :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;
 
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
 
/**
 *
 * @author Coshom
 */
@Entity
@Table(name = "article")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "Article.findByNumCodeBarre", query = "SELECT a FROM Article a WHERE a.numCodeBarre = :numCodeBarre"),
    @NamedQuery(name = "Article.findByNom", query = "SELECT a FROM Article a WHERE a.nom = :nom"),
    @NamedQuery(name = "Article.findByCategorie", query = "SELECT a FROM Article a WHERE a.categorie = :categorie"),
    @NamedQuery(name = "Article.findByPrix", query = "SELECT a FROM Article a WHERE a.prix = :prix"),
    @NamedQuery(name = "Article.findByMarque", query = "SELECT a FROM Article a WHERE a.marque = :marque"),
    @NamedQuery(name = "Article.findByNbCote", query = "SELECT a FROM Article a WHERE a.nbCote = :nbCote"),
    @NamedQuery(name = "Article.findByTotalCote", query = "SELECT a FROM Article a WHERE a.totalCote = :totalCote"),
    @NamedQuery(name = "Article.findByQuantite", query = "SELECT a FROM Article a WHERE a.quantite = :quantite"),
    @NamedQuery(name = "Article.findByQuantiteMax", query = "SELECT a FROM Article a WHERE a.quantiteMax = :quantiteMax"),
    @NamedQuery(name = "Article.findByQuantiteMin", query = "SELECT a FROM Article a WHERE a.quantiteMin = :quantiteMin"),
    @NamedQuery(name = "Article.findByGarantie", query = "SELECT a FROM Article a WHERE a.garantie = :garantie"),
    @NamedQuery(name = "Article.findByDisponibilite", query = "SELECT a FROM Article a WHERE a.disponibilite = :disponibilite"),
    @NamedQuery(name = "Article.findByUrl", query = "SELECT a FROM Article a WHERE a.url = :url")})
public class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "num_code_barre_")
    private String numCodeBarre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 60)
    @Column(name = "nom")
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "detal")
    private String detal;
    @Basic(optional = false)
    @NotNull
    @Column(name = "categorie")
    private int categorie;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "prix")
    private BigDecimal prix;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "marque")
    private String marque;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nbCote")
    private int nbCote;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "total_cote")
    private String totalCote;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantite")
    private int quantite;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantite_max")
    private int quantiteMax;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantite_min")
    private int quantiteMin;
    @Basic(optional = false)
    @NotNull
    @Column(name = "garantie")
    private int garantie;
    @Basic(optional = false)
    @NotNull
    @Column(name = "disponibilite")
    private char disponibilite;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "url")
    private String url;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "numCodeBarre")
    private Collection<Vente> venteCollection;
    @OneToMany(mappedBy = "numCodeBarre")
    private Collection<Reparation> reparationCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "numCodeBarre")
    private Collection<Support> supportCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "numCodeBarre")
    private Collection<Commentaire> commentaireCollection;
 
    public Article() {
    }
 
    public Article(String numCodeBarre) {
        this.numCodeBarre = numCodeBarre;
    }
 
    public Article(String numCodeBarre, String nom, String description, String detal, int categorie, BigDecimal prix, String marque, int nbCote, String totalCote, int quantite, int quantiteMax, int quantiteMin, int garantie, char disponibilite, String url) {
        this.numCodeBarre = numCodeBarre;
        this.nom = nom;
        this.description = description;
        this.detal = detal;
        this.categorie = categorie;
        this.prix = prix;
        this.marque = marque;
        this.nbCote = nbCote;
        this.totalCote = totalCote;
        this.quantite = quantite;
        this.quantiteMax = quantiteMax;
        this.quantiteMin = quantiteMin;
        this.garantie = garantie;
        this.disponibilite = disponibilite;
        this.url = url;
    }
 
    public String getNumCodeBarre() {
        return numCodeBarre;
    }
 
    public void setNumCodeBarre(String numCodeBarre) {
        this.numCodeBarre = numCodeBarre;
    }
 
    public String getNom() {
        return nom;
    }
 
    public void setNom(String nom) {
        this.nom = nom;
    }
 
    public String getDescription() {
        return description;
    }
 
    public void setDescription(String description) {
        this.description = description;
    }
 
    public String getDetal() {
        return detal;
    }
 
    public void setDetal(String detal) {
        this.detal = detal;
    }
 
    public int getCategorie() {
        return categorie;
    }
 
    public void setCategorie(int categorie) {
        this.categorie = categorie;
    }
 
    public BigDecimal getPrix() {
        return prix;
    }
 
    public void setPrix(BigDecimal prix) {
        this.prix = prix;
    }
 
    public String getMarque() {
        return marque;
    }
 
    public void setMarque(String marque) {
        this.marque = marque;
    }
 
    public int getNbCote() {
        return nbCote;
    }
 
    public void setNbCote(int nbCote) {
        this.nbCote = nbCote;
    }
 
    public String getTotalCote() {
        return totalCote;
    }
 
    public void setTotalCote(String totalCote) {
        this.totalCote = totalCote;
    }
 
    public int getQuantite() {
        return quantite;
    }
 
    public void setQuantite(int quantite) {
        this.quantite = quantite;
    }
 
    public int getQuantiteMax() {
        return quantiteMax;
    }
 
    public void setQuantiteMax(int quantiteMax) {
        this.quantiteMax = quantiteMax;
    }
 
    public int getQuantiteMin() {
        return quantiteMin;
    }
 
    public void setQuantiteMin(int quantiteMin) {
        this.quantiteMin = quantiteMin;
    }
 
    public int getGarantie() {
        return garantie;
    }
 
    public void setGarantie(int garantie) {
        this.garantie = garantie;
    }
 
    public char getDisponibilite() {
        return disponibilite;
    }
 
    public void setDisponibilite(char disponibilite) {
        this.disponibilite = disponibilite;
    }
 
    public String getUrl() {
        return url;
    }
 
    public void setUrl(String url) {
        this.url = url;
    }
 
    @XmlTransient
    public Collection<Vente> getVenteCollection() {
        return venteCollection;
    }
 
    public void setVenteCollection(Collection<Vente> venteCollection) {
        this.venteCollection = venteCollection;
    }
 
    @XmlTransient
    public Collection<Reparation> getReparationCollection() {
        return reparationCollection;
    }
 
    public void setReparationCollection(Collection<Reparation> reparationCollection) {
        this.reparationCollection = reparationCollection;
    }
 
    @XmlTransient
    public Collection<Support> getSupportCollection() {
        return supportCollection;
    }
 
    public void setSupportCollection(Collection<Support> supportCollection) {
        this.supportCollection = supportCollection;
    }
 
    @XmlTransient
    public Collection<Commentaire> getCommentaireCollection() {
        return commentaireCollection;
    }
 
    public void setCommentaireCollection(Collection<Commentaire> commentaireCollection) {
        this.commentaireCollection = commentaireCollection;
    }
 
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numCodeBarre != null ? numCodeBarre.hashCode() : 0);
        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 Article)) {
            return false;
        }
        Article other = (Article) object;
        if ((this.numCodeBarre == null && other.numCodeBarre != null) || (this.numCodeBarre != null && !this.numCodeBarre.equals(other.numCodeBarre))) {
            return false;
        }
        return true;
    }
 
    @Override
    public String toString() {
        return "entity.Article[ numCodeBarre=" + numCodeBarre + " ]";
    }
 
}
catégorie :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;
 
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
 
/**
 *
 * @author Coshom
 */
@Entity
@Table(name = "categorie")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Categorie.findAll", query = "SELECT c FROM Categorie c"),
    @NamedQuery(name = "Categorie.findById", query = "SELECT c FROM Categorie c WHERE c.id = :id"),
    @NamedQuery(name = "Categorie.findByNom", query = "SELECT c FROM Categorie c WHERE c.nom = :nom"),
    @NamedQuery(name = "Categorie.findByUrl", query = "SELECT c FROM Categorie c WHERE c.url = :url")})
public class Categorie implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Size(max = 30)
    @Column(name = "nom")
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "url")
    private String url;
 
    public Categorie() {
    }
 
    public Categorie(Integer id) {
        this.id = id;
    }
 
    public Categorie(Integer id, String url) {
        this.id = id;
        this.url = url;
    }
 
    public Integer getId() {
        return id;
    }
 
    public void setId(Integer id) {
        this.id = id;
    }
 
    public String getNom() {
        return nom;
    }
 
    public void setNom(String nom) {
        this.nom = nom;
    }
 
    public String getUrl() {
        return url;
    }
 
    public void setUrl(String url) {
        this.url = url;
    }
 
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        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 Categorie)) {
            return false;
        }
        Categorie other = (Categorie) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
 
    @Override
    public String toString() {
        return "entity.Categorie[ id=" + id + " ]";
    }
 
}
merci de votre aide car je ne vois pas comment faire