2017-12-21 14 views
0

@PatchRequest를 사용하여 API를 테스트하려고 시도했지만 다음 오류가 발생합니다.@PatchRequest를 사용하여 특정 필드 만 업데이트

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/intranet-api] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute batch; SQL [update portal.dbo.DANCE_MASTER set name=?, age=?, gender=?, grade=?,status=?, updated_by=?, updated_ts=? where id=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch] with root cause 
    java.sql.BatchUpdateException: Cannot insert the value NULL into column 'name', table 'ctcportal1.dbo.DANCE_MASTER'; column does not allow nulls. UPDATE fails. 

오류로 인해 모든 필드에 대해 업데이트 된 값을 제공해야합니다. 그러나 테이블의 특정 필드 만 업데이트하려고합니다.

답변

0

java.sql.BatchUpdateException : 테이블 'ctcportal1.dbo.DANCE_MASTER'열 '이름'에 NULL 값을 삽입 할 수 없습니다; 열에 null이 허용되지 않습니다. UPDATE가 실패합니다.

'NULL'값을 NULL 열을에 삽입 할 수 없습니다. DANCE_MASTER 테이블 정의를 확인하고 필요한 모든 열에 값을 제공하십시오.

데이터베이스에 대해 다음 쿼리를 실행하여 값을 지정할 수도 있습니다. 물음표를 적절한 값으로 대체하십시오.

update portal.dbo.DANCE_MASTER 
set name=?, 
age=?, 
gender=?, 
grade=?, 
status=?, 
updated_by=?, 
updated_ts=? 
where id=? 
+0

안녕하세요.하지만 모든 필드가 아닌 특정 필드 만 업데이트하고 싶습니다. 내가 어떻게 할 수 있는지 알 겠어. 그것이 putRequest 또는 PostRequest를 사용하는 대신 patchRequest를 사용하는 나의 이유입니다. – Learner

+0

은 spring dao code 관련 업데이트 기록과 관련된 코드를 공유합니다. – nayakam