Get list of entity fields in Active Objects

Hi everyone!

When I use ‘stream’ methods in the Active Objects library I want to receive entities with all fields filled in some cases.
Earlier I was able to call something like:

ao.stream(SomeEntity.class, Query.select("*"), callback);

But the latest versions of Active Objects do not allow me to use “*” in the query. I have to specify all the required fields explicitly like:

ao.stream(SomeEntity.class, Query.select("ID, FIELD_A, FIELD_B, ...., FIELD_Z"), callback);

Yes, it is a good practice to ask only for the required fields, but sometimes I need to receive all of them. In that case, it will be good to have a way to get a full list of fields from the entity or from the Active Objects library. This will really help in the case when the entity has a lot of fields. Also, this would be good to avoid desynchronization between the list of fields in the query and the fields in the entity definition.

I searched in the following directions.

#1. I found the ‘EntityInfo’ class in the AO library. There is the ‘resolveEntityInfo(Class type)’ method in the ‘EntityManager’ class that returns the ‘EntityInfo’ for the specified entity type. But. This method is protected and thus unavailable outside the library.

#2. It is possible to use something like:

ao.stream(SomeEntity.class, Query.select(), e -> callback.onRowRead(ao.get(SomeEntity.class, e.getID())));

But such a solution has significant drawbacks:

  • It uses one more database connection (and thus may produce the “Dangerous use of multiple connections” Jira warning).
  • There are N additional calls to the database (one per each found record). This is really inefficient.

Is there a way to retrieve entities with all fields filled in AO streams efficiently without the need to manually fill the entity field list?

Thank you.
Denis.