BatchUpdateException: Column 'IdT1' cannot be null
Bonjour j'utilise Hibernate et java pour inserer des objet dans une base mysql:
J'ai deux tables :
Code:
1 2 3 4 5 6 7 8 9
|
T1 :
(id ,nom)
T2 :
(
id
titre
IdT1 : clé etrnager sur T1). |
J'ai insere un objet OBJ1 dans T1 avec un id =1
J'utilise un forumlaire ou je saisie un objet OBJ2 : titre et je recupere idT par code .
je veux persister cet OBJ2.
Code:
1 2 3 4 5 6 7 8 9 10 11
|
....
OBJ2= new OBJ2();
OBJ2.setIdT1(id); (id = 1)
OBJ2.setTitre("blalala";
session.save(OBJ2);
tx.commit()
... |
j'ai cet erreur sur la quelle je seche depuis hier :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
StandardWrapperValve[action]: "Servlet.service()" pour la servlet action a généré une exception
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
.....
Caused by: java.sql.BatchUpdateException: Column 'IdT1' cannot be null
at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:665)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195) |
Avez vous une idée ?