So I have an object with collection. I want to lazily load it at first , but an object can be sent over a network which makes it necessary to fetch all the fields.

      @Entity   
      class Foo
      {
       @Id
       int id;
       @Column
       String name
       @OneToMany
       List<Foo2> = new ArrayList<>();
      }
有帮助吗?

解决方案

So... call a method on the list (like size() for example) to initialize it, or use Hibernate.initialize().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top