I execute a query that should return results in CSV in STDOUT.
When I execute my request in pgAdmin, I successfully get the results.
However, when I execute the same query using hibernate, I get the following exception:
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Failed to retrieve ResultSet
I should not show the structure of the tables, but I know that sql is fine (I copied all the contents of "sql", then executed it in pgAdmin); The request looks like this:
String sql = "COPY (" + sqlQuery + ") TO STDOUT WITH CSV";
Then I execute it like the following:
Query query = getEntityManager().createNativeQuery(sql);
Object result = query.getSingleResult();
In any related questions I found, I saw that OP puts csv in a file instead of stdout.
Is it possible to return csv result using hibernate?
Thanks in advance!