Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

but in JPA annotations, 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...

like image 619
Visus Zhao Avatar asked Aug 22 '11 03:08

Visus Zhao


1 Answers

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

like image 192
Ryan Stewart Avatar answered Oct 20 '22 18:10

Ryan Stewart