Bonjour,
je débute avec Hibernate, et je rencontre un problème à l'execution de mon projet.
Mon fichier Test.java dans le package par défaut est le suivant :
Ensuite le fichier Fwexemple.java contient :
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 import java.util.*; import net.sf.hibernate.*; import com.hibernate.*; public class Test { public static void main(String[] args) throws HibernateException { Session session = HibernateUtil.currentSession();; //Transaction tx = session.beginTransaction(); //Query requette = session.createQuery("FROM Fwexemple"); //List list = requette.list(); Iterator list = session.createSQLQuery("select * FROM Fwexemple","Fwexemple",Fwexemple.class).list().listIterator(); while(list.hasNext()) { Fwexemple user = (Fwexemple)list.next(); System.out.println(user.toString()); } HibernateUtil.closeSession(); } }
et mon erreur généré est la suivante :
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 package com.hibernate; import java.io.Serializable; import net.sf.hibernate.PersistentEnum; /** * 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. */ @SuppressWarnings("deprecation") public class Fwexemple implements Serializable, PersistentEnum { /** * */ private static final long serialVersionUID = 6137497370677628315L; public static final Fwexemple WEB_USER = new Fwexemple(69); public static final Fwexemple PROFIL_C_O_M = new Fwexemple(64); public static final Fwexemple EQUIPE_DÉVELOPPEMENT = new Fwexemple(65); public static final Fwexemple DEMO_USER = new Fwexemple(200); public static final Fwexemple PROFIL_D_E_V1 = new Fwexemple(66); public static final Fwexemple PROFIL_G_R_O_U_P_E = new Fwexemple(67); public static final Fwexemple GESTIONNAIRE_T_H_E_M_6 = new Fwexemple(128); public static final Fwexemple DIMITRI = new Fwexemple(950); public static final Fwexemple USER_INTRANET = new Fwexemple(400); public static final Fwexemple PROFIL_P_R_O_F_I_L = new Fwexemple(79); public static final Fwexemple ANGLAIS = new Fwexemple(21); public static final Fwexemple GUILLAUME = new Fwexemple(90); public static final Fwexemple CYRIL = new Fwexemple(34); public static final Fwexemple VEGA_MESSAGERIE_GROUPE = new Fwexemple(102); public static final Fwexemple ALINE = new Fwexemple(103); public static final Fwexemple UTILISATEUR_P_D_A = new Fwexemple(652); public static final Fwexemple AKIM = new Fwexemple(109); public static final Fwexemple ROBOT = new Fwexemple(106); public static final Fwexemple SERVICE_DÉVELOPPEMENT = new Fwexemple(47); public static final Fwexemple FZEFZ = new Fwexemple(50); public static final Fwexemple CHRISTOPHE = new Fwexemple(909); public static final Fwexemple ADMINISTRATEUR_SYSTEME = new Fwexemple(49); public static final Fwexemple DANIEL = new Fwexemple(908); public static final Fwexemple MAINTENANCE_ATELIER = new Fwexemple(48); public static final Fwexemple RENAUD = new Fwexemple(907); public static final Fwexemple SÉBASTIEN = new Fwexemple(906); public static final Fwexemple OLIVIER = new Fwexemple(904); public static final Fwexemple SERVICE_COMMERCIAL = new Fwexemple(126); public static final Fwexemple JEAN_PIERRE = new Fwexemple(902); public static final Fwexemple BERNARD = new Fwexemple(901); private final int code; protected Fwexemple(int code) { this.code = code; } public int toInt() { return code; } public static Fwexemple fromInt(int code) { switch (code) { case 69: return WEB_USER; case 64: return PROFIL_C_O_M; case 65: return EQUIPE_DÉVELOPPEMENT; case 200: return DEMO_USER; case 66: return PROFIL_D_E_V1; case 67: return PROFIL_G_R_O_U_P_E; case 128: return GESTIONNAIRE_T_H_E_M_6; case 950: return DIMITRI; case 400: return USER_INTRANET; case 79: return PROFIL_P_R_O_F_I_L; case 21: return ANGLAIS; case 90: return GUILLAUME; case 34: return CYRIL; case 102: return MESSAGERIE_GROUPE; case 103: return ALINE; case 652: return UTILISATEUR_P_D_A; case 109: return AKIM; case 106: return ROBOT; case 47: return SERVICE_DÉVELOPPEMENT; case 50: return FZEFZ; case 909: return CHRISTOPHE; case 49: return ADMINISTRATEUR_SYSTEME; case 908: return DANIEL; case 48: return MAINTENANCE_ATELIER; case 907: return RENAUD; case 906: return SÉBASTIEN; case 904: return OLIVIER; case 126: return SERVICE_COMMERCIAL; case 902: return JEAN_PIERRE; case 901: return BERNARD; default: throw new RuntimeException("Unknown value: " + code); } } public String toString () { switch (code) { case 69: return "Web User"; case 64: return "Profil : COM"; case 65: return "Equipe développement"; case 200: return "DEMO USER"; case 66: return "Profil : DEV1"; case 67: return "Profil : GROUPE"; case 128: return "Gestionnaire THEM 6"; case 950: return "Dimitri"; case 400: return "User intranet"; case 79: return "Profil : PROFIL"; case 21: return "ANGLAIS"; case 90: return "Guillaume"; case 34: return "Cyril"; case 102: return "MESSAGERIE GROUPE"; case 103: return "Aline"; case 652: return "Utilisateur PDA"; case 109: return "Akim"; case 106: return "Robot"; case 47: return "Service développement"; case 50: return "COMPTOIRfzefz"; case 909: return "Christophe"; case 49: return "Administrateur Systeme"; case 908: return "Daniel"; case 48: return "MAINTENANCE, ATELIER"; case 907: return "Renaud"; case 906: return "Sébastien"; case 904: return "Olivier"; case 126: return "Service commercial"; case 902: return "Jean-Pierre"; case 901: return "Bernard"; default: return "Unknown value"; } } }
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 30 sept. 2010 09:56:34 net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1.6 30 sept. 2010 09:56:34 net.sf.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found 30 sept. 2010 09:56:34 net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer 30 sept. 2010 09:56:34 net.sf.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml 30 sept. 2010 09:56:34 net.sf.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints 30 sept. 2010 09:56:36 net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.SQLServerDialect 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use outer join fetching: true 30 sept. 2010 09:56:36 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) 30 sept. 2010 09:56:36 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 30 sept. 2010 09:56:36 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://localhost:1433;DatabaseName=Alocpro; 30 sept. 2010 09:56:36 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=sa, password=gcsi} 30 sept. 2010 09:56:36 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory 30 sept. 2010 09:56:36 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use scrollable result sets: true 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use JDBC3 getGeneratedKeys(): true 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: false 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider 30 sept. 2010 09:56:36 net.sf.hibernate.cfg.Configuration configureCaches INFO: instantiating and configuring caches 30 sept. 2010 09:56:36 net.sf.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 30 sept. 2010 09:56:36 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured Exception in thread "main" net.sf.hibernate.MappingException: No persister for: com.hibernate.Fwexemple at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347) at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690) at net.sf.hibernate.impl.SessionImpl.getSQLLoadable(SessionImpl.java:3817) at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3796) at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52) at Test.main(Test.java:12)
Partager