JdbcTemplate.query method not maintaing Order of comma separated string in list

264 Views Asked by At

I have aggregated number of rows using xmlagg in Oracle DB in such a way that after aggregation 445614935 id's DOB is also at first place in Person_DOB column and same is for other id's. But when I fetch this row in java using JdbcTemplate then the order of both the columns values is not maintained. It seems it is getting sorted I want to fetch the data in same order in List in which it is showing in DB.

Query used to aggregate by person_id is

SELECT   rtrim(xmlagg(Xmlelement(e,person_id,',').extract('//text()') order BY person_id).getclobval(),',') AS person_id,
environment,
     rtrim(xmlagg(xmlelement(e,person_dob,',').extract('//text()') ORDER BY 
person_id).getclobval(),',')     AS person_dob 
FROM     ip_co_wr2_usr.person_details
WHERE    status='RFS' 
 GROUP BY environment, 
    ;

Expection after running this query is to get person_id & DOB will be separated by "," maintaing their relationship order, which is happening as well. P1,P2 --> Persion Id and dob_p1,dob_p2 -->DOB of persons

But when we try to map this row in Person Pojo class using JdbcTemplate then , the attribute person_id is coming as "P1,P2" but dob attribute is coming as "dob_p2,dob_p1" . It should be "dob_p1,dob_p2"

  List<Person> triggersList = coJdbcTemplate.query(queryForTrigger,
                new BeanPropertyRowMapper<Person>(
                        Person.class));

enter image description here

0

There are 0 best solutions below