开发者

Hibernate JPA: How to control "Not-Found" behavior when lazy loading a ManyToOne relation?

开发者 https://www.devze.com 2023-03-29 13:00 出处:网络
In older xml based hibernate, one can have this config , <many-to-one ... not-found=\"ignore\" />

In older xml based hibernate, one can have this config ,

<many-to-one ... not-found="ignore" />

but in JPA a开发者_JS百科nnotations, there seems to be nothing similar.

My problem is that our company has SQL REFERENCE definitions like this:

authorId INT NOT NULL DEFAULT 0

which makes all foreign reference default to a "Not-Found" situation. When the relation is loaded lazily, will get an Exception...


Try @NotFound(action=NotFoundAction.IGNORE). It's a Hibernate annotation.

0

精彩评论

暂无评论...
验证码 换一张
取 消