How to test whether lazy loaded JPA collection is initialized?

前端 未结 3 1735
时光说笑
时光说笑 2020-12-04 21:05

I have a service that gets a JPA entity from outside code. In this service I would like to iterate over a lazily loaded collection that is an attribute of this entity to see

3条回答
  •  感动是毒
    2020-12-04 21:58

    For eclipselink, users cast the collection you are trying to access to an org.eclipse.persistence.indirection.IndirectList, and then call its isInstantiated() method. The following link has more information:

    http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/indirection/IndirectList.html#isInstantiated.

提交回复
热议问题