Cannot Select entity ID through OQL

Hi fellow mendix developers, When trying to replace several retrieves activities with a single OQL statement, I came accross an error that was caused by selecting the ID of an entity.   Could not find result association stamgegevens$busrijkarakteristiek.ID in target object. at BusinessLogicLayer.BLL_Busdienst_RetrieveFromDatabaseAll (JavaAction : 'Execute OQL statement') at BusinessLogicLayer.UT_Busdienst_RetrieveAll (SubMicroflow : 'BLL_Busdienst_RetrieveFromDatabaseAll') What I’m trying to do is to get the association (Reference) ID. When using an Retrieve Activity, these Reference ID’s are included. However, When trying to retrieve the entity through OQL, I cannot slect the reference ID. Anyone knows how to do this? Any help is much appreciated.   Thanks, Jan
2 answers

Hi Jan,

The reference ID's are stored in another table so you'll need to do a join activity on the OQL. I use the following OQL statement for a related functionality:

SELECT Attribute
FROM Module.Entity
LEFT OUTER JOIN Module.Entity/Module.Entity_RelatedEntity/Module.RelatedEntity as RelatedEntity
WHERE RelatedEntity/ID IS NULL



Hi Marius,

Thanks for you reply. My OQL query is:

Select A.Naam, entity2.ID
FROM Module1.entity1 A
LEFT OUTER JOIN Module1.entity1_relatedEntity/Module2.entity2 as entity2

When I change the ID attribute into Name, it works fine. But the ID is causing an error.