Bonjour à tous,
Je suis débutante en programmation avec Hibernate, j'utilise MySQL aussi.

voici mon problème; j'ai généré mes fichiers de mapping ainsi que le fichier de configuration hibernate.cfg.xml.

j'ai instancié mes classes et j'ai réussi à les ajouter à ma base de données

en essayant de faire un mapping de type one to many entre la classe societe et client, et après avoir vérifier que mon code est bon j'obtiens l'erreur suivante:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'id_societe' in 'field list'.

voila mes fichiers de mapping, sachant que mes classes ont été générées automatiquement merci hibernate :

Client.hbm
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
<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > 
 
<hibernate-mapping package="modele"> 
<class name="Client" table="client"> 
<id 
column="id_client" 
name="IdClient" 
type="integer" 
> 
<generator class="identity" /> 
</id> 
<property 
column="prenom_client" 
length="45" 
name="PrenomClient" 
not-null="true" 
type="string" 
/> 
<property 
column="nom_client" 
length="45" 
name="NomClient" 
not-null="true" 
type="string" 
/> 
<many-to-one name="societe" column="id_societe" class="Societe" cascade="all"/> 
</class> 
</hibernate-mapping>
societe.hbm
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
<?xml version="1.0"?> 
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" > 
 
<hibernate-mapping package="modele"> 
<class name="Societe" table="societe"> 
<id 
column="id_societe" 
name="IdSociete" 
type="integer" 
> 
<generator class="identity" /> 
</id> 
<property 
column="nom_societe" 
length="45" 
name="NomSociete" 
not-null="true" 
type="string" 
/> 
<set name="clients" inverse="true" cascade="all" > 
<key column="id_societe" /> 
<one-to-many class="Client"/> 
</set> 
</class> 
</hibernate-mapping>
classe de test:
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
package modele.dao; 
 
import java.util.Iterator; 
import java.util.List; 
 
import modele.Client; 
import modele.Societe; 
 
import org.hibernate.HibernateException; 
import org.hibernate.Session; 
import org.hibernate.Transaction; 
 
 
 
public class TestMain { 
 
/** 
* @param args 
* @throws net.sf.hibernate.HibernateException 
* @throws HibernateException 
* @throws net.sf.hibernate.HibernateException 
*/ 
public static void main(String[] args) throws HibernateException, net.sf.hibernate.HibernateException 
{ 
Session session= (Session) HibernateSessionFactory.currentSession(); 
 
Transaction tx = session.beginTransaction(); 
 
// Client c=new Client(); 
// c.setNomClient("menia"); 
// c.setPrenomClient("nadjah"); 
// session.save(c); 
// 
// Societe s= new Societe(); 
// s.setNomSociete("rodrigue"); 
// session.save(s); 
 
//test sur le mapping one to many 
Societe s0=new Societe(); 
s0.setNomSociete("peugeot"); 
//g rajouté cette ligne qui ne marche tjr pas :( 
session.save(s0); 
Client c0=new Client(); 
c0.setNomClient("khadra"); 
c0.setPrenomClient("yasmina"); 
System.out.println("ajout avec succès"); 
//s0.getClients().add(c0); 
s0.addClient(c0); 
session.save(c0); 
session.flush(); 
 
tx.commit(); 
 
 
// affichage des données à partir dela table 
List list=session.createQuery("from Client").list(); 
Iterator iterate= list.iterator(); 
while (iterate.hasNext()) 
{ 
Client c1= (Client) iterate.next(); 
System.out.println("nom client:" +c1.getNomClient()); 
System.out.println("prenom client:"+ c1.getPrenomClient()); 
 
 
} 
List list1 =session.createQuery("from Societe").list(); 
Iterator iterate1= list1.iterator(); 
while (iterate1.hasNext()) 
{ 
Societe s1= (Societe) iterate1.next(); 
System.out.println("nom societe:" +s1.getNomSociete()); 
} 
 
 
 
try 
{ 
HibernateSessionFactory.closeSession(); 
} catch (org.hibernate.HibernateException e) 
{ 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
} 
}
Pourriez vous m'aider s'il vous plait.
merci d'avance

Je me permets de vous afficher tous ce que j'obtiens sur ma console:
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
21 mai 2013 16:54:53 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
21 mai 2013 16:54:53 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
21 mai 2013 16:54:53 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
21 mai 2013 16:54:53 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
21 mai 2013 16:54:53 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
21 mai 2013 16:54:53 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
21 mai 2013 16:54:54 org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Client.hbm
21 mai 2013 16:54:55 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: modele.Client -> client
21 mai 2013 16:54:55 org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Societe.hbm
21 mai 2013 16:54:56 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: modele.Societe -> societe
21 mai 2013 16:54:56 org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Produit.hbm
21 mai 2013 16:54:57 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: modele.Produit -> produit
21 mai 2013 16:54:57 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
21 mai 2013 16:54:57 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
21 mai 2013 16:54:57 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
21 mai 2013 16:54:57 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: modele.Societe.clients -> client
21 mai 2013 16:54:57 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
21 mai 2013 16:54:57 org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
21 mai 2013 16:54:57 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
21 mai 2013 16:54:57 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
21 mai 2013 16:54:57 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
21 mai 2013 16:54:57 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test
21 mai 2013 16:54:57 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=menia, password=****}
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.6.11
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.3 ( $Date: 2006-07-26 17:26:47 +0200 (Wed, 26 Jul 2006) $, $Revision: 5553 $ )
21 mai 2013 16:54:57 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
21 mai 2013 16:54:57 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
21 mai 2013 16:54:57 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: null
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
21 mai 2013 16:54:57 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
21 mai 2013 16:54:57 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
21 mai 2013 16:54:57 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
21 mai 2013 16:54:57 net.sf.ehcache.config.Configurator configure
ATTENTION: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Users/nmenia/workspace/hibernateTest/WebContent/WEB-INF/lib/ehcache-0.6.jar!/ehcache-failsafe.xml
21 mai 2013 16:54:57 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
21 mai 2013 16:54:57 org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
21 mai 2013 16:54:57 org.hibernate.util.JDBCExceptionReporter logExceptions
ATTENTION: SQL Error: 1054, SQLState: 42S22
21 mai 2013 16:54:57 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: Unknown column 'id_societe' in 'field list'
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [modele.Client]
	at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1777)
	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)
	at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
	at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
	at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:240)
	at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
	at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
	at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
	at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
	at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
	at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
	at modele.dao.TestMain.main(TestMain.java:33)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'id_societe' in 'field list'
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:3124)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1149)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
	at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1759)
	... 14 more