Bonjour,

Alors voila mon soucis. Je développe actuellement une application qui utilise hibernate. En lecture, pas de problème, par contre, à la premiere sauvegarde que je veux faire, j'obtiens ca comme erreur :

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
Hibernate: update oneirawak.j_avatar set id_race=?, id_carte=?, id_classe=?, nom=?, x=?, y=?, argent=?, nourriture=?, nourriture_max=?, pv=?, pv_max=?, pm=?, pm_max=?, sexe=?, vue=?, force=?, intelligence=?, attaque=?, defense=?, attaque_mag=?, defense_mag=?, experience=?, niveau=?, mouvement=?, mouvement_max=?, direction=? where id_avatar=?
19:55:16,576  WARN JDBCExceptionReporter:77 - SQL Error: 1064, SQLState: 42000
19:55:16,576 ERROR JDBCExceptionReporter:78 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'force=3, intelligence=3, attaque=3, defense=3, attaque_mag=3, defense_mag=3, exp' at line 1
19:55:16,576 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
	at fr.oneirawak.servlets.action.ActionAvatarDeplacer.executeAction(ActionAvatarDeplacer.java:106)
	at fr.oneirawak.servlets.ServletAction.traitementMessage(ServletAction.java:68)
	at fr.oneirawak.servlets.ServletAction.doPost(ServletAction.java:40)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'force=3, intelligence=3, attaque=3, defense=3, attaque_mag=3, defense_mag=3, exp' at line 1
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
	... 26 more
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
	at fr.oneirawak.servlets.action.ActionAvatarDeplacer.executeAction(ActionAvatarDeplacer.java:106)
	at fr.oneirawak.servlets.ServletAction.traitementMessage(ServletAction.java:68)
	at fr.oneirawak.servlets.ServletAction.doPost(ServletAction.java:40)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'force=3, intelligence=3, attaque=3, defense=3, attaque_mag=3, defense_mag=3, exp' at line 1
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1666)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1082)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
	... 26 more
La portion de code qui appele ca c'est :
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
 
// Code appelant la fonction
Session hSession = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = hSession.beginTransaction();
 
avatarHome = new JAvatarHome();
JAvatar avatar = avatarHome.trouveParId(1);
avatar.setY(25);
avatarHome.sauvegarder(avatar);
tx.commit();
 
 
// avatarHome.sauvegarder :
public void sauvegarder(JAvatar instance) {
   try {
       sessionFactory.getCurrentSession().saveOrUpdate(instance);
       System.out.println("Sauvegarde de l'avatar ok");
   } catch (RuntimeException re) {
       System.out.println("Echec de la sauvegarde de l'avatar");
       throw re;
   }
}
Javatar.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2 ao?t 2008 15:53:29 by Hibernate Tools 3.2.0.CR1 -->
<hibernate-mapping>
    <class name="fr.oneirawak.servlets.tables.JAvatar" table="j_avatar" catalog="oneirawak">
        <id name="idAvatar" type="int">
            <column name="id_avatar" />
            <generator class="assigned" />
        </id>
        <many-to-one name="JRace" class="fr.oneirawak.servlets.tables.JRace" fetch="select">
            <column name="id_race" not-null="true" />
        </many-to-one>
        <many-to-one name="JCarte" class="fr.oneirawak.servlets.tables.JCarte" fetch="select">
            <column name="id_carte" not-null="true" />
        </many-to-one>
        <many-to-one name="JClasse" class="fr.oneirawak.servlets.tables.JClasse" fetch="select">
            <column name="id_classe" not-null="true" />
        </many-to-one>
        <property name="nom" type="string">
            <column name="nom" not-null="true" />
        </property>
        <property name="x" type="int">
            <column name="x" not-null="true" />
        </property>
        <property name="y" type="int">
            <column name="y" not-null="true" />
        </property>
        <property name="argent" type="int">
            <column name="argent" not-null="true" />
        </property>
        <property name="nourriture" type="int">
            <column name="nourriture" not-null="true" />
        </property>
        <property name="nourritureMax" type="int">
            <column name="nourriture_max" not-null="true" />
        </property>
        <property name="pv" type="int">
            <column name="pv" not-null="true" />
        </property>
        <property name="pvMax" type="int">
            <column name="pv_max" not-null="true" />
        </property>
        <property name="pm" type="int">
            <column name="pm" not-null="true" />
        </property>
        <property name="pmMax" type="int">
            <column name="pm_max" not-null="true" />
        </property>
        <property name="sexe" type="byte">
            <column name="sexe" not-null="true" />
        </property>
        <property name="vue" type="byte">
            <column name="vue" not-null="true" />
        </property>
        <property name="force" type="int">
            <column name="force" not-null="true" />
        </property>
        <property name="intelligence" type="int">
            <column name="intelligence" not-null="true" />
        </property>
        <property name="attaque" type="int">
            <column name="attaque" not-null="true" />
        </property>
        <property name="defense" type="int">
            <column name="defense" not-null="true" />
        </property>
        <property name="attaqueMag" type="int">
            <column name="attaque_mag" not-null="true" />
        </property>
        <property name="defenseMag" type="int">
            <column name="defense_mag" not-null="true" />
        </property>
        <property name="experience" type="int">
            <column name="experience" not-null="true" />
        </property>
        <property name="niveau" type="int">
            <column name="niveau" not-null="true" />
        </property>
        <property name="mouvement" type="int">
            <column name="mouvement" not-null="true" />
        </property>
        <property name="mouvementMax" type="int">
            <column name="mouvement_max" not-null="true" />
        </property>
        <property name="direction" type="char">
            <column name="direction" length="1" not-null="true" />
        </property>
    </class>
</hibernate-mapping>
J'ai vérifié, avec des "get" sur toutes les valeurs d'avatar et tout est bien récupéré et renseigné. Bref, j'ai le bon enregistrement, mais au moment de la sauvegarde, ca foire et je ne comprend pas pourquoi.

La ligne at fr.oneirawak.servlets.action.ActionAvatarDeplacer.executeAction(ActionAvatarDeplacer.java:106) correspond au tx.commit(); mais dans mon log, j'ai bien "Sauvegarde de l'avatar ok".

Merci d'avance