Skip to content

Commit

Permalink
[hibernate#1984] Return typeName column metadata for results
Browse files Browse the repository at this point in the history
This information is now available and it's required when working with JSON.
  • Loading branch information
DavideD committed Sep 20, 2024
1 parent 8d11bf2 commit 7a34897
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,25 @@ private static class MetaData implements ResultSetMetaData {

private final List<String> columns;
private final List<ColumnDescriptor> descriptors;
private final String[] typeNames;


public MetaData(List<String> columnNames, List<ColumnDescriptor> columnDescriptors) {
columns = columnNames;
descriptors = columnDescriptors;
typeNames = initTypeNames( columnDescriptors );
}

private static String[] initTypeNames(List<ColumnDescriptor> columnDescriptors) {
if ( columnDescriptors == null ) {
return null;
}
final String[] typeNames = new String[columnDescriptors.size()];
int i = 0;
for ( ColumnDescriptor columnDescriptor : columnDescriptors ) {
typeNames[i++] = columnDescriptor.typeName();
}
return typeNames;
}

@Override
Expand Down Expand Up @@ -1412,9 +1427,7 @@ public String getCatalogName(int column) {

@Override
public String getColumnTypeName(int column) {
// This information is in rows.columnDescriptors().get( column-1 ).dataType.name
// but does not appear to be accessible.
return null;
return typeNames[column - 1];
}

@Override
Expand Down

0 comments on commit 7a34897

Please sign in to comment.