本文介绍了jpa返回什么集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JPA(在这种情况下为Eclipselink)是否总是在实体具有列表的情况下返回IndirectList?该列表可以吗,还是应该将其转换为另一个列表(也许是链表)?

Does JPA ( Eclipselink in this case) always return IndirectList where Entity have a List? Is ok that list or It should be converted to another list( maybe linkedlist)?

推荐答案

分析

如果我们查看EclipseLink的 IndirectList的API ,它说:

TopLink将在实例变量中放置一个IndirectList. 包含域对象是从数据库中读取的.与第一 消息发送到IndirectList,内容从 数据库并恢复到正常的收集/列表/向量"行为.

TopLink will place an IndirectList in the instance variable when the containing domain object is read from the datatabase. With the first message sent to the IndirectList, the contents are fetched from the database and normal Collection/List/Vector behavior is resumed.

如果我们查看间接列表源,我们将看到,所有工作都委托给它的原始集合,就像API所说的那样.

If we view IndirectList sources, we will see, that all the work is delegated to it's original collection, just like API says.

是的,它始终会返回用IndirectList包装的指定集合.由于它将所有内部工作委托给包装的集合,因此保留了工作方式.

Yes, it always does return your specified collection wrapped with IndirectList. Since it delegates all its internal work to the wrapped collection, it preserves the way it works.

是的,可以使用IndirectList.您无需进行转换,只需定义所需的任何类型的集合,不必担心IndirectList,因为它是透明管理的.

Yes, it is okay to use IndirectList. You don't convert, you just define any type of collection you want and don't worry about IndirectList, since it is managed transparently.

这篇关于jpa返回什么集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 21:17