I'v been trying to find a solution for this via google but didn't find anything, so I hope that there is a way to resolve my problem.
I have written a java application where ther user can enter some arbitrary SQL and export the result to various different outputs like simple CSV file export, export as insert statement etc.. Due to this, the statement is not known in advance. Now I used a result transformer to obtain the column names from the select, which worked fine. However, since some of the queries return a large number of records, thus resulting in a huge memory usage, I wanted to rewrite this to use a cursor and immediately write each record when it is delivered from the database, instead of waiting for the complete select to finish. So now I'm using ScrollableResults to fetch the rows individually and this part works. However, I have no idea how to retrieve the column names now, because the result transfomer is not fired anymore. I don't understand why though, because I would have expected that the result transfomer should be called for each row, no matter how the row is retrieved. So either I'm doing something wrong, or I missing something.
I would really appreciate it if there were any help for this. Thanks!
|