OQL Casting Column Issue in View Entity

0
I am trying to fetch Mendix ID column in OQL in View Entity. However, this is creating an association and in the Preview, it is showing as Object. I have tried casting into multiple types but no luck. The error is "CAST expression must be of a primitive type."   Query: SELECT CAST(Event.id as LONG) as EventID   Studio Pro: 10.19.0
asked
6 answers
2

I have been testing around and this seems to be a limitation of the Entity view/OQL Editor. A workaround is to copy the ID in another attribute. This can be done in an after-create microflow or a batch microflow for existing data.

answered
1

Hi all, 

we will need this as well.

One of use case: have a View Entity to add aggregated data (which we want to reuse then) and still have ID there (for example to allow retrieve record selected in UI)

(and we don't want add any additional unique attribute just as a workaround for not fully accessible ID)

 

Thank you.

answered
1

Mendix 10.21 release notes state:

  • We fixed the validation of OQL queries in Studio Pro. Studio Pro now accepts casting an object ID to a different data type. (Ticket 240854)

See: https://docs.mendix.com/releasenotes/studio-pro/10.21/#10210

 

Should be solved in my understanding.

answered
0

Workaround is only workable for specific cases.

In general: we do not want to copy ID in another attribute for tons of entity types.

I hope Mendix can fix Entity view/OQL Editor so SELECT CAST(ID as STRING) is again ok

 

answered
0

Tested: In OQL it still works so existing code not affected, so just Entity view/OQL Editor issue.

Using GUID to generically get objects from OQL query results.

 

answered
0

I do have the same issue with the view/OQL Editor. It needs to be fixed.

 

My OQL is executed in a java action. So I use a hack to change the OQL dynamically.

 

statement = statement.replaceFirst("SELECT", "SELECT cast(");
statement = statement.replaceFirst("/ID", "/ID as Long)");

 

answered