ActiveObjects.stream() not populating encapsulated entities

AO Streaming API (Products & News - Work Life by Atlassian) is promoted as a preferred way to access AO entities faster than using find() or get().

However, using find/get the full object graph is returned, but the streaming api does not.
(example, entity with OneToMany association.)

A work around is to stream the parent objects, and then for each parent object stream the child objects - but this is a LOT of extra code and becomes impractical if the object graph is more complex.

Based on searching, earlier versions of AO used to fully populate when streaming, so this is either a bug, or an annoying feature.

2 Likes

Writing here beacuse there’s not much documentation about the stream API.
Hopefully someone will stumple on this post as I did and get some answers.

What I found was that the stream api will only fetch the ID of an entity unless you specifically select the columns. (@Preloading annotation did nothing btw. if someone thinks of that).

Original query:
Query childCountQuery = Query.select()
.from(MyDataEntity.class)
.where(“SPACE_KEY = ?”, spaceKey);

New Query:
Query childCountQuery = Query.select(“ID,INHERIT_PAGE_ID”)
.from(MyDataEntity.class)
.where(“SPACE_KEY = ?”, spaceKey);

I have not tested this with OneToMany relationship but it might work by joining the other table. The OneToMany relationship doesn’t create a column. But for the Many part actually get an ID reference back to the One part… if that makes sense.

4 Likes