Return 如果 "no row with the given identifier exists" 则为空

Return null if "no row with the given identifier exists"

我在两个 table 之间建立了多对一关系。我赶上

no row with the given identifier exists

据我了解,如果 table A 无法使用给定 ID 绑定 table B,就会发生这种情况。那么,我该如何避免呢? return 空对象会很好。我试图用 nullable=true 注释绑定字段,但这并不能解决问题。

我也设置了@ManyToOne(optional = true),但是没有效果

好的,我找到了 solution。我应该用 @NotFound(action=NotFoundAction.IGNORE) 语句注释绑定字段。