We need more information. Spring isn't a JDBC implementation, so what do you want to use? Jdbc and with Spring's JdbcTemplate? Hibernate? Hibernate's implementation of JPA?
With JdbcTemplate there is a queryForMap method, where if you write your sql as a crosstab query, you can make the first column values be the column names and the description the values where you just pass the SQL string to the queryForMap method.
But which data access technology you are using tells us a good deal of what you should do.
1. (Sorry, if my intention is not clear. Thanks for the pointers)
2. I got what I wanted as shown above code. Just simple JDBC Template is enough.
Yep, that will work perfectly.
The approach that I was talking about would make it the query responsible for setting things up. But writing a crosstab query. But thinking about it, I am not sure you can write a crosstab query for that. But if you did then you can run