Java ConstraintViolationException中的特定信息
我对列名称和电子邮件有唯一的约束,当JPA抛出ConstraintViolationException时,我需要关于违反了哪个列的信息,但我只得到:Java ConstraintViolationException中的特定信息,java,postgresql,hibernate,jpa,jdbc,Java,Postgresql,Hibernate,Jpa,Jdbc,我对列名称和电子邮件有唯一的约束,当JPA抛出ConstraintViolationException时,我需要关于违反了哪个列的信息,但我只得到: { "timestamp": 1501144724882, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.dao.DataIntegrityViolationException", "mes
{
"timestamp": 1501144724882,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.dao.DataIntegrityViolationException",
"message": "could not execute statement; SQL [n/a]; constraint [uk_6dotkott2kjsp8vw4d0m25fb7]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement",
"path": "/add"
}
我使用PostgreSQL数据库。对于约束的名称,您将获得DataIntegrityViolationException,这是一个什么约束。首先签入您尝试添加/保存元素的表。它看起来像是自动生成的约束,因此如果没有access db,很难说这个约束是干什么的。您会得到DataIntegrityViolationException,因为约束的名称
UK6dotkott2KJSP8VW4D0M25FB7
签入db它是什么约束。首先签入您尝试添加/保存元素的表。它看起来像是自动生成的约束,因此如果没有access db,很难说这个约束是用来做什么的。发布您的查询/语句我用Spring JpaRepository保存它,使用方法saveit如果您在问题中添加代码和数据库查询会更好我不使用sql查询。我使用Spring数据发布您的查询/语句我使用方法save通过Spring JpaRepository保存如果您在问题中添加代码和数据库查询会更好我不使用sql查询。我使用Spring数据