You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To address the issue of validating the "Value" field at the interface level in Apollo OpenAPI, you can use the @NotBlank annotation on the value field in the ServerConfig class. This annotation ensures that the field is not null and not empty, preventing SQL constraint violations related to null values.
This will ensure that the "Value" field is validated before reaching the database layer, thus avoiding the DataIntegrityViolationException you encountered [1].
描述bug
在接口层面没有校验参数的合法性,导致请求打到了数据库层才抛出异常
复现
通过如下步骤可以复现:
{"exception":"org.springframework.dao.DataIntegrityViolationException","message":"could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement [Cause: NULL not allowed for column \"Value\"; SQL statement:\ninsert into \"Item\" (\"Id\", \"DataChange_CreatedBy\", \"DataChange_CreatedTime\", \"DataChange_LastModifiedBy\", \"DataChange_LastTime\", \"DeletedAt\", \"IsDeleted\", \"Comment\", \"Key\", \"LineNum\", \"NamespaceId\", \"Type\", \"Value\") values (default, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23502-214]]","status":500.0,"timestamp":"2025-04-03T14:46:12.475"}
期望
可以在接口层面就提前校验参数的合法性
截图
额外的细节和日志
The text was updated successfully, but these errors were encountered: