0

How can i force the database connector to return LinkedHashMap to ensure that resultset is in same order as in db?

vijay dhanakodi
  • 175
  • 1
  • 14

3 Answers3

1

Though the DB resultset is unordered, we can still extract data from columns or map columns to the target we desire. So may i know in which scenario you're expecting the ordered resultset? and the another question which struck me after seeing your question was, why the resultset is unordered in the first place?

0

@vijay dhanakodi The best way would be to use data weave once you get the result and that arrange it accordingly example

%dw 1.0

%output application/java

{ firstColumn: payload.keyName as :object {class:"java.util.LinkedHashMap"}

}

Zahid
  • 59
  • 10
0

SQL drivers do not maintain or guarantee the order of columns in returned resultset. Why is order important? I had similar situation, see this question.

Manik Magar
  • 1,403
  • 2
  • 10
  • 20