MySQLIntegrityConstraintViolationException: Column cannot be null
Bonjour à tous,
Voici ma table sgllienmouvement (que je ne peux pas modifier) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
mysql> show columns from sgllienmouvement;
+-----------------------+---------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------------------+------+-----+---------------------+----------------+
| id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| idsglmouvement | bigint(20) unsigned | NO | MUL | 0 | |
| idsglmouvementautre | bigint(20) unsigned | NO | MUL | 0 | |
| idsidevenementpatient | bigint(20) unsigned | NO | MUL | 0 | |
| dateheuredeb | datetime | NO | | 0000-00-00 00:00:00 | |
| etat | varchar(255) | NO | | | |
| idfhausermaj | bigint(20) unsigned | NO | | 0 | |
| datemaj | datetime | NO | | 0000-00-00 00:00:00 | |
+-----------------------+---------------------+------+-----+---------------------+----------------+
8 rows in set (0.01 sec) |
La colonne idsglmouvement est mappée ainsi :
Code:
1 2 3 4 5
|
<many-to-one class="domain.model.Sglmouvement"
fetch="join" name="sglmouvement">
<column name="idsglmouvement" not-null="false" />
</many-to-one> |
Mon problème c'est que lorsque je lance un update d'un objet Sgllienmouvement, si l'objet sglmouvement est null, l'exception suivante est lancée :
Code:
1 2 3
|
GRAVE: Servlet.service() for servlet [Faces Servlet] in context with path [/XXX] threw exception [Could not execute JDBC batch update] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'idsglmouvement' cannot be null |
J'ai tenté de faire un "update sgllienmouvement set idsglmouvement = null where id = ?" directement dans MySQL et malgré un avertissement "Column 'idsglmouvement' cannot be null", la requête est bien exécutée et il me remplace bien le NULL par 0 qui est la valeur par défaut.
Comment faire pour résoudre mon problème ?
Merci pour vos réponse.
Cordialement,