Database Connector - Mendix reserved words conflicting with external database table column names
We are trying to read data from a Salesforce database table in our application using Database Connector and a non-persistent entity in Mendix. The external database table contains 3 columns (among others) with names that are Mendix reserved words (id, createddate, type). The attributes in the non-persistent entity need to be identical to the column names in the external database table for it to pull through when we select the data but we cannot create entity attributes with those reserved words… and so the Execute Query activity from DB Connector fails due to a mismatch in the column names and the entity attributes. Has anyone else encountered this and found a work around? Thank you in advance, Greg
I’ve not tried this, but would using an “AS” in your SQL to rename the conflicting columns work? For example,
SELECT id as MxID, createddate as MxCreatedDate FROM …
Then use MxID and MxCreatedDate in your NPE.
Try using aliases in your sql statement. The alias must match the column name in your object result.
For example: SELECT type AS 'TypeAlias' FROM table;
Edit: beaten by Robert, I can confirm this works!
Hi Robert and Ruud,
It worked exactly as you say!
Thank you both for taking the time to reply, it’s much appreciated.
It does work for me unfortunately. I get the error below
Caused by: com.mendix.modules.microflowengine.MicroflowException: com.mendix.systemwideinterfaces.MendixRuntimeException: java.lang.RuntimeException: The entity type 'NativeMobile.wp_posts' does not contain the primitive 'ID' as specified in the query.
at NativeMobile.Get_wp_posts (JavaAction : 'Execute query')