If anybody's interested, I think I finally found the reason for the exception. I compared the generated DDL in MySQL with both of the above versions of the mapping file. It seems that the not-null constraint is not generated if the column tag is nested. On the other hand it IS generated if the column attribute is used. So the exception I got was probably due to some implementation error of mine because I obviously inserted null values into columns that shouldn't be null. But the database didn't enforce the constraint so I never realized my error.
DDL with mapping containing nested column tag:
Code:
CREATE TABLE `bproccov` (
`id` int(11) NOT NULL default '0',
`bproc_idBproc` int(11) default NULL,
'ipurel_idRel` int(11) default NULL,
`orgunit_idOrgunit` int(11) default NULL,
`product_id` int(11) default NULL,
...);
DDL with mapping containing column as attribute:
Code:
CREATE TABLE `bproccov` (
`id` int(11) NOT NULL default '0',
`bproc_idBproc` int(11) NOT NULL default '0',
'ipurel_idRel` int(11) NOT NULL default '0',
`orgunit_idOrgunit` int(11) NOT NULL default '0',
`product_id` int(11) NOT NULL default '0',
...);
Even though I know that some people don't like it if you just scream out 'that's a bug in Hibernate', I'll go as far out on the limb ;): I think that's a bug in Hibernate and I will search through the bug database if something similar has already been reported...
Cheers
Martin