Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 80400d7

Browse files
Update spring-bean-validation.md
1 parent d20b180 commit 80400d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎docs/advanced/spring-bean-validation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,17 @@ public class PersonService {
520520

521521
代码地址:https://github.com/Snailclimb/springboot-guide/tree/master/source-code/advanced/bean-validation-demo
522522

523+
## `@NotNull` vs `@Column(nullable = false)`(重要)
523524

525+
在使用 JPA 操作数据的时候会经常碰到 `@Column(nullable = false)` 这种类型的约束,那么它和 `@NotNull` 有何区别呢?搞清楚这个还是很重要的!
526+
527+
- `@NotNull`是 JSR 303 Bean验证批注,它与数据库约束本身无关。
528+
- `@Column(nullable = false)` : 是JPA声明列为非空的方法。
529+
530+
总结来说就是即前者用于验证,而后者则用于指示数据库创建表的时候对表的约束。
524531

525532
## TODO
526533

527-
- [ ] JPA 数据库级别参数约束验证
528534
- [ ] 原理分析
529535

530536
## 参考

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /