Which is the best way to export a JPA query result in a CSV format? I tried opencsv but it wants a java.sql.ResultSet object and I don't understand how to create it. I tried the following code
public ResultSet getAllUsersMap() {
String query = "SELECT p from Participant p ORDER BY p.lastName";
ResultSet rs = (ResultSet) em.createQuery(query).getResultList();
return rs;
}
but I receive the exception java.lang.ClassCastException: java.util.Vector cannot be cast to java.sql.ResultSet