Bonjour,
je rencontre actuellement un soucis avec une requete que je veux effectuer via hibernate.
Voici les différents codes :
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 public static List getUtilisateurList(int id) { Session session = HibernateUtil.currentSession(); List utilisateurs = null; try { // utilisateurs = UtilisateurDAO.getInstance().findAll("nom"); Query query = session .createQuery(" from Utilisateur where id in ( select utilisateur from Affectation where fonction=" + id+")"); utilisateurs = query.list(); } catch (Exception ex) { ex.printStackTrace(); } return utilisateurs; }
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 <class name="Utilisateur" table="COMPTE"> <id column="ID_COMPTE" name="id" type="java.math.BigDecimal" > </id> <property column="LOGIN" length="10" name="login" not-null="true" type="string" /> <property column="MATRICULE" length="10" name="matricule" not-null="false" type="string" /> <property column="NOM" length="50" name="nom" not-null="true" type="string" /> <property column="PRENOM" length="50" name="prenom" not-null="true" type="string" /> <property column="MAIL" length="100" name="mail" not-null="false" type="string" /> <property column="PASSWORD" length="50" name="password" not-null="false" type="string" /> <property column="CODEGRADE" length="10" name="codeGrade" not-null="false" type="string" /> <property column="CODAGT" name="codAgt" not-null="false" type="java.math.BigDecimal" /> <property column="ADMIN" name="admin" not-null="false" type="string" /> </class> </hibernate-mapping>En fait j'utilise cette requete pour alimenter une liste déroulante sur ma page jsp mais actuellement elle ne renvoie rien
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 <class name="Affectation" table="AFFECTATION" lazy="false" > <id column="ID_AFFECTATION" name="id" type="java.math.BigDecimal" > </id> <many-to-one name="utilisateur" column="ID_COMPTE" not-null="true" class = "Utilisateur" fetch="join" lazy="false" /> <many-to-one name="fonction" column="ID_FONCTION" not-null="false" class = "Fonction" fetch="join" lazy="false" /> <property column="CHEFSTRUCTURE" length="1" name="chefStructure" not-null="false" type="string" /> <property column="CODE_ACTION" length="1" name="codeAction" not-null="false" type="string" /> <property column="DATE_ACTION" name="dateAction" not-null="false" type="timestamp" /> <property column="TELGSM" length="14" name="telGsm" not-null="false" type="string" /> <property column="TEL1" length="14" name="telephone1" not-null="false" type="string" /> <property column="TEL2" length="14" name="telephone2" not-null="false" type="string" /> <property column="FAX" length="14" name="fax" not-null="false" type="string" /> <property column="DATE_EFFET" name="dateEffet" not-null="false" type="date" /> <property column="DATE_FIN" name="dateFin" not-null="false" type="date" /> <property column="COMMENTAIRE" length="255" name="comment" not-null="false" type="string" /> <many-to-one name="structure" column="ID_STRUCTURE" not-null="true" class = "Structure" fetch="join" lazy="false" /> </class> </hibernate-mapping>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <select name="utilisateurs"> <option value="vide"></option> <% Iterator it2 = GetList.getUtilisateurList(10).iterator(); String p=null; while(it2.hasNext()){ Utilisateur util =(Utilisateur)it2.next(); p=util.getNom()+" "+util.getPrenom(); %> <option value="<%=util.getNom()%>.' '.<%=util.getPrenom()%>"> <%=p%></option> <%}%> </select>
Je pense que ca peut venir des noms de colonne, car j'avoue je sais pas trop lequel utiliser dans le fichier de mapping.
Partager