org.hibernate.exception.ConstraintViolationException
今天遇到这个错误,网上查了下,大多说是有必填字段没有填,搞了很久没搞定,最后发现不是因为这个问题,而是因为字段设置了唯一值,如果表中已存在此记录,再插入则报此错误。
Hibernate: insert into membership.t_user (login_id, password, type, status, email, mobile, first_name, last_name, nickname, gender, birthday, country, region, creation_date, last_update_date, join_confirm_date, activation_date, deactivation_date, register_code, join_expire_date) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
org.springframework.dao.DataIntegrityViolationException:
could not insert: [com.igen6.sac.ms.bean.TUser]; SQL [insert into
membership.t_user (login_id, password, type, status, email, mobile,
first_name, last_name, nickname, gender, birthday, country, region,
creation_date, last_update_date, join_confirm_date, activation_date,
deactivation_date, register_code, join_expire_date) values (?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null];
nested exception is
org.hibernate.exception.ConstraintViolationException: could not insert:
[com.igen6.sac.ms.bean.TUser]