OQL Execute in Microflow fails with View Entity due to unexpected ID column (Mendix 10.24.19)

0
Hi everyone,I am working with a View Entity in Mendix 10.24.19 (OQL v2 enabled) and trying to retrieve data using Execute OQL Statement inside a microflow.What I am doing:I pass the following OQL query as a string:OQLSELECT AuditName AS NameFROM AppMain.AuditUserViewI use a Non-Persistable Entity as the result entity. Problem:The query execution fails with the error:Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.RuntimeException: Could not find result association ID in target object. Actual Output (from database / OQL result)Even though my query only selects AuditName, the result includes an auto-generated ID column:NameID7562s-TestEntry Christian 11Sept2020-SFS GAT FY21227713256158963171 Observation:The View Entity automatically includes an ID column, even though it is not defined in my query.My result entity does not have this ID attribute, which seems to cause the issue.Questions:Why does OQL return an ID column automatically for View Entities?Is it mandatory to include ID in the SELECT statement when querying a View Entity?How should the Non-Persistable Entity be structured to avoid this error?Is this specific to OQL v2 behavior?
asked
1 answers
0

The issue is happening because the returned result structure from OQL does not match the structure of your Non-Persistable Entity.


With View Entities, Mendix internally handles the result set, and if the query does not define the result shape properly, additional metadata/identifier columns can appear during mapping.


Instead of trying to map the generated ID, I normally keep the OQL result exactly aligned with the expected output.


A common approach is:

SELECT 
    AuditName AS Name
FROM AppMain.AuditUserView
GROUP BY AuditName


The idea is:

  • Every attribute in SELECT should also exist in GROUP BY
  • The returned columns will match the aliases you define
  • Since the GROUP BY does not contain the View Entity ID column, the ID will not be part of the result set
  • The Non-Persistable Entity attributes should use the exact same names as the OQL aliases


Example:

Non-Persistable Entity:

AuditResult
 └── Name (String)


OQL:

SELECT 
    AuditName AS Name
FROM AppMain.AuditUserView
GROUP BY AuditName


Now the runtime mapping becomes: AuditName → Name without expecting the generated ID column.


This approach keeps the OQL result clean and avoids the mapping error.


Kindly mark this as the accepted answer if it helps.

answered