mysql field id doesnt have a default value_mysql – Field ‘id’ doesn’t have a default value? – Stack …

  • Post author:
  • Post category:mysql


For me the issue got fixed when I changed

to

in my Person.hbm.xml.

after that I re-encountered that same error for an another field(mobno). I tried restarting my IDE, recreating the database with previous back issue got eventually fixed when I re-create my tables using (without ENGINE=InnoDB DEFAULT CHARSET=latin1; and removing underscores in the field name)

CREATE TABLE `tbl_customers` (

`pid` bigint(20) NOT NULL,

`title` varchar(4) NOT NULL,

`dob` varchar(10) NOT NULL,

`address` varchar(100) NOT NULL,

`country` varchar(4) DEFAULT NULL,

`hometp` int(12) NOT NULL,

`worktp` int(12) NOT NULL,

`mobno` varchar(12) NOT NULL,

`btcfrom` varchar(8) NOT NULL,

`btcto` varchar(8) NOT NULL,

`mmname` varchar(20) NOT NULL

)

instead of

CREATE TABLE `tbl_person` (

`person_id` bigint(20) NOT NULL,

`person_nic` int(10) NOT NULL,

`first_name` varchar(20) NOT NULL,

`sur_name` varchar(20) NOT NULL,

`person_email` varchar(20) NOT NULL,

`person_password` varchar(512) NOT NULL,

`mobno` varchar(10) NOT NULL DEFAULT ‘1’,

`role` varchar(10) NOT NULL,

`verified` int(1) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I probably think this due to using ENGINE=InnoDB DEFAULT CHARSET=latin1; , because I once got the error org.hibernate.engine.jdbc.spi.SqlExceptionHelper – Unknown column ‘mob_no’ in ‘field list’ even though it was my previous column name, which even do not exist in my current table. Even after backing up the database(with modified column name, using InnoDB engine) I still got that same error with old field name. This probably due to caching in that Engine.



版权声明:本文为weixin_28737399原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。