Bonjour tout le monde,
Je veux instancier un iterartor mais il ne veut l'instancier, je ne comprend pas pourquoi.
C'est cette ligne là qui ne fonctionne pas
Je vous donne tout de même le code source, le voici:
Code : Sélectionner tout - Visualiser dans une fenêtre à part Iterator<TContact> lespersonnes=new Iterator <TContact>();
Je vous remercie de votre aide
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 package com.minosis.hibernate.dao; import java.util.Iterator; import net.sf.hibernate.HibernateException; import net.sf.hibernate.Session; import net.sf.hibernate.Transaction; import com.minosis.hibernate.TContact; import com.minosis.bdd.*; import com.minosis.hibernate.base.BaseTContactDAO; /** * This class has been automatically generated by Hibernate Synchronizer. * For more information or documentation, visit The Hibernate Synchronizer page * at http://www.binamics.com/hibernatesync or contact Joe Hudson at joe@binamics.com. * * This is the object class that relates to the t_contact table. * Any customizations belong here. */ public class TContactDAO extends BaseTContactDAO { public void ajoutpersonne(String nom,String prenom,Integer age) throws HibernateException { try { Session session=HibernateUtil.currentSession(); Transaction tx=session.beginTransaction(); TContact contact=new TContact(); contact.setNom(nom); contact.setPrenom(prenom); contact.setAge(age); session.save(contact); tx.commit(); HibernateUtil.closeSession(); } catch(Exception e) { e.printStackTrace(); } } public Iterator getlespersonnes() throws HibernateException { Iterator<TContact> lespersonnes=new Iterator <TContact>(); try { Session session=(Session) HibernateUtil.currentSession(); lespersonnes=(Iterator)session.find("FROM TContact").iterator(); HibernateUtil.closeSession(); } catch(Exception e) { e.printStackTrace(); } return lespersonnes; } }
Partager