-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: MySQLIntegrityConstraintViolationException
PostPosted: Thu Aug 04, 2011 11:17 am 
Newbie

Joined: Thu Aug 04, 2011 11:00 am
Posts: 1
Hi,

I have a table named "sgllienmouvement" (that I can't modify) :

Code:
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)


The column idsglmouvement is mapped like that :

Code:
<many-to-one class="domain.model.Sglmouvement"
         fetch="join" name="sglmouvement">
         <column name="idsglmouvement" not-null="false" />
      </many-to-one>


When I update an object Sgllienmouvement, if the attribute sglmouvement is null, the following exception is thrown :

Code:
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


I tried to execute "update sgllienmouvement set idsglmouvement = null where id = ?" in MySQL and in spite of the warning "Column 'idsglmouvement' cannot be null", the request is correctly executed and the NULL value of idsglmouvement is replaced by a 0 that is the default value of the column.

How can I solve the problem ?

Thanks,

Florian


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.