Navigation to Collection Elements


Greetings ObjectDB team,

Suppose I have a collection typed field (list/map/set...) in my persistent object of class X.

Can I navigate (as opposed to using JOIN) to individual elements (in JPA & JDO) ?



x.list.get(10).get("key") // the element itself is a map

How about arrays like x.array[1] and x.array[1][2] ?

Thanks & Best Regards


Yes, you can navigate from any managed entity object to any other reachable managed entity object. All the expressions that you wrote are valid, if x is a managed entity object (or persistent object in JDO) in both JPA and JDO, assuming the owner EntityManager / PersistenceManager is open.

If the referenced objects are not already in memory they will be loaded automatically from the database. This is sometimes referred to as transparent persistence (or transparent activation / retrieval).

When using ObjectDB you can also use these expressions in queries but it is not recommended, because it is not JPA/JDO portable (it is an extension of ObjectDB) and it also leads to performance penalty.

ObjectDB Support

Thank you for your fast reply.

I really meant it to be done in JPA/JDO queries.

How about arrays like x.array[1] and x.array[1][2] ?

If such navigations in queries lead to performance penalty, how slow is it and would you recommend something better ?



If you query a class that does not have too many objects (e.g. up to one million) then every supported query might be fine.

Indexes, for example, are not supported in handling such expressions.

Indexes are supported in handling more conventional collection expressions (by using JPA's JOIN or JDO's contains).

The array expressions that you wrote are not supported in queries, and anyway, collections are preferred over arrays when using JPA/JDO (and they might be even more efficient).

ObjectDB Support