bonjour j'ai un message d'erreur d'hibernate que je comprend pas est ce que quelqu'un pourrait m'aider.


la BDD c'est:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
Incidents (incident_id, #incident_type_id, #assigned_user, #creater_user, ......)
User(userId, ......)
Incident_Type(incident_type_id, ......)
voici mon fichier principal fichier de mapping:
Incidents.hbm.xml
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
 
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
	"-//Hibernate/Hibernate Mapping DTD//EN"
	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
 
<hibernate-mapping package="...business.mapping">
	<class
		name="Incidents"
		table="Incidents"
	>
		<meta attribute="sync-DAO">false</meta>
		<id
			name="Id"
			type="integer"
			column="incident_id"
		>
			<generator class="increment"/>
		</id>
 
 
		<!-- foreign key : IncidentType -->
		<many-to-one
			name="IncidentTypeId"
			class="IncidentsType"
			column="incident_type_id"
		/>
 
		<!-- foreign key : assigned User -->
		<many-to-one
			name="AssignedUser"
			class="User"
			column="userId"
			insert="false"
			update="false"
		/>
 
		<!-- foreign key : creater User -->
		<many-to-one
			name="CreaterUser"			
			class="User"
			column="userId"
			insert="false"
			update="false"
		/>
 
		<property
			name="Title"
			column="title"
			type="string"
			not-null="true"
			length="45"
		/>
 
 
		<!-- foreign key from IncidentLevel -->
		<many-to-one
			name="IncidentLevelId"
			class="IncidentLevel"
			column="incident_level_id"
		/>
 
 
 
		<!-- foreign key from IncidentState -->
		<many-to-one
			name="IncidentStateId"
			column="incident_state_id"
			class="IncidentState"
		/>
 
		..............
 
	</class>	
</hibernate-mapping>
Voici la fonction de mon DAO :
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
 
public Incidents getIncident(int incidentId) {
 
		try{
			log.info("get the incident with the id "+ incidentId);
			Session session = HibernateUtil.getCurrentSession();
			Transaction transaction = session.beginTransaction();
 
 
			Incidents incident = (Incidents) session.get(Incidents.class, incidentId);
 
			transaction.commit();
			HibernateUtil.closeSession();
			return incident;
		}
 
		catch(HibernateException e){
			log.error("Exception - DataAccessException occurs : "+e.getMessage()+" on complete getIncident().");
			return null;
		}			
	}

et je crée une classe de test :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
public class HibernateTest {
	public static void main(String[] args) {
		IncidentDAO dao = new IncidentDAOImpl();
 
		Incidents incident = dao.getIncident(1);
		System.out.println(incident.getTitle());		
	}
}
j'ai l'erreur 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
ATTENTION: SQL Error: 1054, SQLState: 42S22
2 juin 2009 16:06:19 org.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: Unknown column 'incidents0_.userId' in 'field list'
2 juin 2009 16:06:19 org.hibernate.event.def.DefaultLoadEventListener onLoad
INFO: Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [......business.mapping.Incidents#1]
	at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.loader.Loader.loadEntity(Loader.java:1285)
	at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141)
	at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126)
	at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2496)
	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:387)
	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:368)
	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166)
	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
	at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:249)
	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:123)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:561)
	at org.hibernate.impl.SessionImpl.get(SessionImpl.java:556)
	at .....business.dao.IncidentDAOImpl.getIncident(IncidentDAOImpl.java:83)
	at test.HibernateTest.main(HibernateTest.java:14)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'incidents0_.userId' in 'field list'
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
	at com.mchange.v2.sql.filter.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:68)
	at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:567)
	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
	at org.hibernate.loader.Loader.getResultSet(Loader.java:1197)
	at org.hibernate.loader.Loader.doQuery(Loader.java:366)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
	at org.hibernate.loader.Loader.loadEntity(Loader.java:1271)
	... 13 more
2 juin 2009 16:06:19 .....business.dao.IncidentDAOImpl getIncident
GRAVE: Exception - DataAccessException occurs : could not load an entity: [.....business.mapping.Incidents#1] on complete addIncident().
à aucun moment j'ai utilisé incidents0_ , je sais pas comment hibernate l'a ajouté ?!