Hi,
We are on Hibernate core 3.3.1.GA. A requirement is forcing us to do a straight SQL query. Part of it specifies that we need to return the column names along with the values.
Looking through the API, I don't see a clear way to get at the metadata.
So, for now we did a straight JDBC query, but as you can imagine that is a hassle to escape the parameters.
For reference we ended up doing something like this:
Code:
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
int columnCount = resultSetMetaData.getColumnCount();
int columnStartIndex = 1;
int columnStopIndex = columnCount - 1;
while (resultSet.next()) {
Map<String, Object> result = new HashMap<String, Object>(columnCount);
for (int i = columnStartIndex; i < columnStopIndex; i++) {
result.put(resultSetMetaData.getColumnName(i), resultSet.getObject(i));
}
results.add(result);
Best wishes,
Grant