firegloves / MemPOI

A library to simplify export from database to Excel files using Apache POI :japanese_goblin:
MIT License
57 stars 7 forks source link

Provide ways to run MemPOI sync. #72

Closed jfarjona closed 11 months ago

jfarjona commented 1 year ago

Is your feature request related to a problem? Please describe. I am trying to use MemPOI with Spring Data, specifically with a NamedParameterJdbcTemplate. Each query should fill a worksheet. As MemPOI only accepts PreparedStatements, that are later executed, it makes it impossible to use it because Spring doesn't give access to the PreparedStatement. Using a callback method doesn't work because by the time MemPOI executes the query, the PreparedStatement has been already closed by Spring.

Describe the solution you'd like A way to execute each MempoiSheet and add it to the MempoiBuilder object with the query already executed. Could be a method called "query". Then the Future object can assemble the data. Another way would be to have some sort of integration with Spring Data, which is widely used, perhaps by accepting a JdbcOperations object that runs the query.

Describe alternatives you've considered I could not find a simple way to work around this issue. I could create a fake PreparedStatement class that would have a cache of all records from the ResultSet and a fake ResultSet that will reproduce the results of the query... absurd.

firegloves commented 1 year ago

Hi @jfarjona , your request makes sense, but I don't understand how I can get the ResultSet out of the JdbcOperations. As far as I can understand I can execute the query providing a ResultSetExtractor, but without the ResultSet the changes to be made would really be a lot. I'm still thinking about it, if you have suggestions they are welcome

firegloves commented 1 year ago

@jfarjona what's wrong with this approach in your scenario?