@Basic(fetch = FetchType.LAZY) does not work?

前端 未结 7 1642
执念已碎
执念已碎 2020-12-17 09:17

I use JPA (Hibernate) with Spring. When i want to lazy load a Stirng property i use this syntax:

@Lob
@Basic(fetch = FetchType.LAZY)
public String getHtmlSum         


        
7条回答
  •  庸人自扰
    2020-12-17 09:50

    from the specification of JPA they say that even if you use annotate a property to be fetched lazily, this is not guaranteed to be applied, so the properties may or may not be loaded lazily (depends on the implementer of JPA), however if you specify that you should fetch them Eagerly then the JPA implementer must load them eagerly.

    Bottom line: @Basic(fetch = FetchType.LAZY) may or may not work, depends on the JPA implementer.

提交回复
热议问题