I think the code above is outdated since Axon.ivy 6.0.
I think you can But it should be possible to solve this problem by using JPA: https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.datamodeling.html#ivy-persistence-api
Then you could easily access the peristence persistence unit or the EntityManager itself and query any objects out of the database. Similiar Similar as shown here: https://answers.axonivy.com/questions/1102/how-to-use-jpa-entity-manager-instead-of-ivy-entity-manager/1103
The rough steps to use JPA in an ivy project:
1. define an external database as data
store:
https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.configuration.html#ivy-database
1. map it to a persistence unit provider:
https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.datamodeling.html#ivy-editors-persistence-configuration
1. generate JPA pojos: https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.datamodeling.html#ivy-persistence-entityclasses