简体   繁体   中英

Mule DataWeave DB results to Arraylist of Objects

I am trying to convert a Db resultset into an ArrayList of "Flight" objects using DataWeave in Mule 3.7.3.

My Code is as shown below. I am no expert in DataWeave :(

%dw 1.0
%type user=:object {class: "java.util.ArrayList<MyFlightClass>"}
%output application/java
---
payload map ((payload01 , indexOfPayload01) -> {
    airlineName: payload01.airlineName,
    departureDate: payload01.takeOffDate as :string,
    destination: payload01.toAirport,
    origination: payload01.fromAirport,
    price: payload01.price as :number
})

Instead of getting an ArrayList of MyFlightClass, I am getting an ArrayList of LinkedHashMap. I'm sure I'm missing something trivial :(.

assign each as flight object

%dw 1.0
%output application/java
---
payload map ((payload01 , indexOfPayload01) -> {
    airlineName: payload01.airlineName,
    departureDate: payload01.takeOffDate as :string,
    destination: payload01.toAirport,
    origination: payload01.fromAirport,
    price: payload01.price as :number
} as :object {class: "com.mulesoft.training.Flight"})

Cheers,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM