EclipseLink provides a Query hint that allows the results to be returned as a List of Maps (DatabaseRecords) instead of a List of Object[].
"eclipselink.result-type"="Map"
See, org.eclipse.persistence.ResultType , QueryHints
ymajoros wrote:
Hi,
Is there a simple way to migrate code like this to jpa/eclipselink?
// get connection, statement
ResultSet rs = statement.executeQuery(maCommande);
while (rs.next()) {
String code = rs.getString("code_etude");
// ...
}
In order to use jpa-provided connection pools, to have all statements
closed in all cases without try-finally blocks, ...
Is there a simple solution? Native queries return an array with unnamed
columns, we really want to use methods like
rs.getString("my_column_name"). We can't use SqlResultSetMapping, as the
queries are too complex to be mapped.
Yannick