org.hibernate.HibernateException: The database returned no natively generated identity value

org.hibernate.HibernateException: The database returned no natively generated identity value

problem

使用hibernate新增数据报错

org.hibernate.HibernateException: The database returned no natively generated identity value

reason

table的字段id不是自增特性

solution

设置id为自增特性

-- 将id字段设置为主键,不为空,自增即可
alter table User modify id int(11) not Null auto_increment primary key;
上一篇:使用Shiro安全框架出现的堆栈溢出异常:*Error


下一篇:TCP编程函数和步骤