Adds support for qualifying columns with table.
Adds support common in other ResultSet implemenatations for qualifying column names with table name to distinguish potentially duplicate column names in a join of two or more tables from one another. The expected format is {table_name}.{column_namne}, where column_name is the actuall designated column name and not the column label.
This commit is contained in:
committed by
Juergen Hoeller
parent
2d942a6e91
commit
cb48077698
@@ -99,7 +99,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
if (rsmd != null) {
|
||||
int columnCount = rsmd.getColumnCount();
|
||||
this.columnLabelMap = CollectionUtils.newHashMap(columnCount);
|
||||
this.columnLabelMap = CollectionUtils.newHashMap(columnCount * 2);
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String key = rsmd.getColumnLabel(i);
|
||||
// Make sure to preserve first matching column for any given name,
|
||||
@@ -107,6 +107,15 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
|
||||
if (!this.columnLabelMap.containsKey(key)) {
|
||||
this.columnLabelMap.put(key, i);
|
||||
}
|
||||
// Also support column names prefixed with table name
|
||||
// as in {table_name}.{column.name}.
|
||||
String table = rsmd.getTableName(i);
|
||||
if (table != null && !table.isEmpty()) {
|
||||
key = table + "." + rsmd.getColumnName(i);
|
||||
if (!this.columnLabelMap.containsKey(key)) {
|
||||
this.columnLabelMap.put(key, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user