Bonjour,

J'ai une application qui tourne sur tomcat, je me connecte à une base de données MySQL et j'utilise le framwork Hibernate.
Je définis pas mal de critères sur mes requetes et ça marche bien (j'utilise la classe Criteria) sauf quand je veux limiter mes résultats j'arrive à afficher plus rien!

j'ai ajouté cette méthode

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
   protected void addCritereLimit() throws Exception {
    	criteres.setMaxResults(50);
    }

dans cette classe

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
 
 
public abstract class ListManager extends BaseManager {
    protected Criteria criteres;
 
    protected DataUserChoices paramUtilisateur;
 
    protected static String CRITERE_EQ = "eg";
 
    protected static String CRITERE_SUP = "sup";
 
    protected static String CRITERE_INF = "inf";
 
    protected static String CRITERE_DIF = "dif";
 
    protected static String CRITERE_IN = "in";
 
    protected static String CRITERE_lik = "lik";
 
    protected String NOM_ALIAS_TABLE_BASE;
 
    protected String NOM_PROPRIETE_TABLE_SSA;
 
    protected static String NOM_ALIAS_TABLE_RESERVATION = "infosReservation";
 
    protected void initialize(DataUserChoices paramUtilisateur)
            throws Exception {
        super.initialize(paramUtilisateur.getClientSegment());
        this.paramUtilisateur = paramUtilisateur;
        this.initialize();
    }
 
    protected abstract void initialize() throws Exception;
 
    protected void addCritereSSA() throws Exception {
        List<String> ssasDansCritere = new ArrayList<String>();
        Iterator iSsa = paramUtilisateur.getListSsa().iterator();
        while (iSsa.hasNext()) {
            com.capgemini.orcis.web.model.Ssa currentSsa = (com.capgemini.orcis.web.model.Ssa) iSsa
                    .next();
            if (currentSsa.getCriterChecked().equals("true")) {
                ssasDansCritere.add(currentSsa.getLibelle());
            }
 
        }
        if (!ssasDansCritere.isEmpty()) {
 
            criteres = criteres.createAlias(NOM_PROPRIETE_TABLE_SSA,
                    "ssapresent");
            criteres.add(Restrictions.in("ssapresent.nomssa", ssasDansCritere
                    .toArray()));
        }
 
    }
 
    protected void addCritereSegment() throws Exception {
        criteres.add(Restrictions.eq(this.NOM_ALIAS_TABLE_BASE + ".nscsnum",this.paramUtilisateur.getClientSegment()));
    }
 
    protected void addCritereLimit() throws Exception {
    	criteres.setMaxResults(50);
    }
 
    protected void addCritereInfosReservation() throws Exception {
        Iterator iInfoReservation = this.paramUtilisateur
                .getListReservationFields().iterator();
        while (iInfoReservation.hasNext()) {
            Field champsSelectionne = (Field) iInfoReservation.next();
            Iterator icritereRes = champsSelectionne.getListCriteresValues()
                    .iterator();
            while (icritereRes.hasNext()) {
                CritereValue critereRes = (CritereValue) icritereRes.next();
                if (!critereRes.getValue().equals("")) {
                    this.criteres.add(Restrictions.eq(
                            NOM_ALIAS_TABLE_RESERVATION + "."
                                    + champsSelectionne.getAttributeName(),
                            critereRes.getValue()));
                }
            }
            // if(critereRes.getCritere())
        }
    }
 
    protected void addCritereInfosDonnes() throws Exception {
        Iterator iInfoDonnes = this.paramUtilisateur.getListDataFields()
                .iterator();
        // Pour chaque critere sur une info de donnée
        // On ajoute le critere SQL associé
        while (iInfoDonnes.hasNext()) {
            Field champsSelectionne = (Field) iInfoDonnes.next();
            Iterator icritereInfo = champsSelectionne.getListCriteresValues()
                    .iterator();
            // Si le critère est l'égalité
            while (icritereInfo.hasNext()) {
                CritereValue critereInfo = (CritereValue) icritereInfo.next();
                if (critereInfo.getCritere().equals(CRITERE_EQ)) {
                    this.criteres.add(Restrictions.eq(NOM_ALIAS_TABLE_BASE
                            + "." + champsSelectionne.getAttributeName(),
                            critereInfo.getValue()));
                }
                // Si le critère est la supériorité
                else if (critereInfo.getCritere().equals(CRITERE_SUP)) {
                    this.criteres.add(Restrictions.gt(NOM_ALIAS_TABLE_BASE
                            + "." + champsSelectionne.getAttributeName(),
                            critereInfo.getValue()));
                }
                // Si le critère est l'infériorité
                else if (critereInfo.getCritere().equals(CRITERE_INF)) {
                    this.criteres.add(Restrictions.lt(NOM_ALIAS_TABLE_BASE
                            + "." + champsSelectionne.getAttributeName(),
                            critereInfo.getValue()));
                }
                // Si le critère est la différence
                else if (critereInfo.getCritere().equals(CRITERE_DIF)) {
                    this.criteres.add(Restrictions.not(Restrictions.eq(
                            NOM_ALIAS_TABLE_BASE + "."
                                    + champsSelectionne.getAttributeName(),
                            critereInfo.getValue())));
                }
            }
        }
    }
 
    /**
     * ajout des critères et renvoie la liste des critères
     * @return List
     * @throws Exception
     */
 
    public List getListDonnees() throws Exception {
 
        //this.addCritereSegment();
    	this.addCritereLimit();
        if (this.paramUtilisateur.getListSsa().size() > 0) {
            this.addCritereSSA();
        }
        this.addCritereInfosDonnes();
        this.addCritereInfosReservation();
 
        return this.criteres.list();
    }
Merci de votre aide