un save qui cause org.hibernate.exception.SQLGrammarException:
Bonjour,
ma classe de persistance a les attributs suivants :
Integer idConfig;
String designation;
Date dateConfig;
Short int1;
Short ext1;
Short int2;
Short ext2;
Short int3;
Short ext3;
Short int4;
Short ext4;
voici ma fonction pour faire la mise à jour
Code:
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
|
public void changeconfig(Integer idroue,Integer ext1,Integer ext2,Integer ext3,Integer ext4,Integer int1,Integer int2,Integer int3,Integer int4){
Session session;
session = HibernateSessionFactory.getSession();
FConfigRouesDAO dao = new FConfigRouesDAO();
// 2. Find by ID
FConfigRoues roue = dao.findById(idroue);
// 3. Change information
Short ext=0;
roue.setExt1(ext);
/*roue.setExt2(ext2);
roue.setExt3(ext3);
roue.setExt4(ext4);
roue.setInt1(int1);
roue.setInt2(int2);
roue.setInt3(int3);
roue.setInt4(int4);*/
// 4. Start the transaction
//Transaction tx = dao.getSession().beginTransaction();
Transaction tx = session.beginTransaction();
// 5. Update the user record with the changes
session.save(roue);
// 6. Commit the transaction (write to database)
tx.commit();
session.close();
} |
j'obtiens cette exception
Exception in thread "main" 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:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at company.BL.Factory.main(Factory.java:471)
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 'int1=1, ext1=1, int2=1, ext2=1, int3=1, ext3=1, int4=0, ext4=0 where Id_Config=1' at line 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1213)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:912)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 8 more