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)?
If we look at EclipseLink's IndirectList's API, it says:
To use an IndirectList: declare the appropriate instance variable with type IndirectList (jdk1.1) or Collection/List/Vector (jdk1.2).
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.
If we view IndirectList sources, we will see, that all the work is delegated to it's original collection, just like API says.
Does JPA ( Eclipselink in this case) always return IndirectList where Entity have a List?
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.
Is ok that list or It should be converted to another list( maybe linkedlist)?
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.
Since List
is an interface the JPA provider is free to return any implementation. EclipseLink rerurns an IndirectList
where a List
is used. This is perfectly fine since the IndirectList
is a List
.
For the record or for future reference, it is generally best practice to use interfaces with JPA.