I’m writing a web application using Spring/Hibernate that displays a report to a user, I would like to allow the user to export the results to a CSV file.
Can anyone suggest an efficient way to output Hibernate query results to a CSV file?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Hibernate is for object-relational mapping. If you don’t have objects on the other end, what’s the point?
Spring doesn’t prohibit mixing and matching JDBC and Hibernate. Use the best approach for the problem at hand. Straight JDBC sounds best in your case.
Also, have a look at Spring’s AbstractJExcelView if this is a web app. Perhaps you can write a straight DAO to get the data, send it back to the controller, and have it render a JExcelView back to the browser. The user will see the data as an Excel spreadsheet in the browser. They will have the option of saving it as a .csv file from the browser. Nice and clean.