【发布时间】:2018-01-02 21:26:31
【问题描述】:
我对列名和电子邮件有唯一的限制,当 JPA 抛出 ConstraintViolationException 时,我需要知道哪一列被违反了,但我只得到:
{
"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 数据库。
【问题讨论】:
-
发布您的查询/声明
-
我通过 Spring JpaRepository 使用方法 save 保存它
-
问题里加代码和数据库查询会更好
-
我不使用sql查询。我使用 Spring Data
标签: java postgresql hibernate jpa jdbc