Java – JPA: even if the getter method is used, it will not load or delay loading I hope so?

Can you briefly explain what the following phrase means:

My question is:

>Does this mean that lazy may not be loaded even after the getlazyloadedobj() method_ loaded_ object? > If the answer to the first question is "yes", what is the answer returned from the getlazyloadedobj () method? > If lazy_ loaded_ Object is an agent. I still don't understand what will change Please explain it to me

Thank you first

Solution

1) Yes

2) Subclass of model object, which contains additional code to set properties when calling getter

3) You can imagine the object you get when calling. For example, getperson () accesses a lazily loaded personentity, which may look like this:

public class LazyPersonEntity extends PersonEntity {

  private PersonEntity lazilyLoadedPerson;

  @Override
  public String getName() {
    if (lazilyLoadedPerson == null) {
      lazilyLoadedPerson = runQueryToLoadPerson();
    }
    return lazilyLoadedPerson.getName();
  }
}

Obviously, this is not what the generated code really looks like, but functionally it's happening Therefore, when you execute getperson (), you get a lazypersonentity instance, and there is still no query before you call getname ()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>