Map PIVOT data to object

18 views
Skip to first unread message

Andrey Rogov

unread,
May 5, 2024, 10:07:21 AMMay 5
to mybati...@googlegroups.com
Hi. 
Time reports are built on the basis of SQL SERVER PIVOT . 
Depending on the dates range I get different columns as a result
for January 01/01/2024 - 01/10/2024, for February 02/01/2024 - 02/10/2024. 
How to provide mapping to an object if the columns change names?

regards

Andrey

Iwao AVE!

unread,
May 5, 2024, 6:51:08 PMMay 5
to mybati...@googlegroups.com
Hello Andrey,

Assuming your question is about naming dynamic columns in PIVOT query, answers in these threads may help.

I didn't test it myself, but the mssql-jdbc seems to support such a statement, so it should work with MyBatis as well.

Mapping to a map (e.g. HashMap) should be pretty straightforward.
Mapping to a custom object is possible, but might be difficult if the number of returned columns is unknown.

If you have any difficulty, please create a minimal repro project and share it on your GitHub repo.
I will take a look when I have time.
Here are some project templates and examples.

Regards,
Iwao

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CAAJ_J15zsQBqfZ58%3DaNF4wfxEJwJ8eytxxZbUkfaSN2ESVNSuw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages