Search code examples
muleanypoint-studio

Force the order of SQL fields (columns) with Mule Database JDBC Connector?


I'm learning Mule and things have been progressing well enough. Right now I'm getting records from a Microsoft SQL Server database using the Mule Database Connector with the JDBC driver and I'm getting my records successfully, but the order of the fields (columns) in the payload are different than what I've specified in my SQL SELECT statement. For instance, my SELECT statement is something like this:

SELECT UserId, FirstName, LastName FROM Users

But when the records are added to the payload, they are not kept in the column order I want, which is "UserId, FirstName, LastName". Instead, it will be random. "LastName" might be first, then "UserId", then "FirstName".

Is there a way that I can control the order that these columns get added to the LinkedList that is created in the payload?

Thanks!


Solution

  • Payload is internally depend on Java HashMap, which is non-ordered in nature. You will not get ordered payload to retain same columns.