Index: src/main/java/org/modeshape/jcr/JcrQueryManager.java =================================================================== --- src/main/java/org/modeshape/jcr/JcrQueryManager.java (revision 1858) +++ src/main/java/org/modeshape/jcr/JcrQueryManager.java (working copy) @@ -513,24 +513,28 @@ public String[] getColumnTypes() { if (columnTypes == null) { // Discover the types ... - Columns columns = results.getColumns(); - List types = new ArrayList(columns.getColumnCount()); - for (Column column : columns) { - String typeName = null; - Table table = schemata.getTable(column.getSelectorName()); - if (table != null) { - Schemata.Column typedColumn = table.getColumn(column.getPropertyName()); - typeName = typedColumn.getPropertyType(); - } - if (typeName == null) { - // Might be fabricated column, so just assume string ... - typeName = PropertyType.nameFromValue(PropertyType.STRING); - } - types.add(typeName); + columnTypes = loadColumnTypes(results.getColumns()); + } + return columnTypes.toArray(new String[columnTypes.size()]); + } + + protected List loadColumnTypes(Columns columns) { + List types = new ArrayList(columns.getColumnCount()); + for (Column column : columns) { + String typeName = null; + Table table = schemata.getTable(column.getSelectorName()); + if (table != null) { + Schemata.Column typedColumn = table.getColumn(column.getPropertyName()); + typeName = typedColumn.getPropertyType(); + } + if (typeName == null) { + // Might be fabricated column, so just assume string ... + typeName = PropertyType.nameFromValue(PropertyType.STRING); } - columnTypes = types; + types.add(typeName); } - return columnTypes.toArray(new String[columnTypes.size()]); + + return types; } /** @@ -1119,7 +1123,10 @@ } protected static class JcrSqlQueryResult extends JcrQueryResult { - private final List columnNames; + + private final List columnNames; + private boolean addedScoreColumn; + private boolean addedPathColumn; protected JcrSqlQueryResult( JcrSession session, String query, @@ -1127,8 +1134,14 @@ Schemata schemata ) { super(session, query, graphResults, schemata); List columnNames = new LinkedList(graphResults.getColumns().getColumnNames()); - if (!columnNames.contains(JCR_SCORE_COLUMN_NAME)) columnNames.add(0, JCR_SCORE_COLUMN_NAME); - if (!columnNames.contains(JCR_PATH_COLUMN_NAME)) columnNames.add(0, JCR_PATH_COLUMN_NAME); + if (!columnNames.contains(JCR_SCORE_COLUMN_NAME)) { + columnNames.add(0, JCR_SCORE_COLUMN_NAME); + addedScoreColumn = true; + } + if (!columnNames.contains(JCR_PATH_COLUMN_NAME)) { + columnNames.add(0, JCR_PATH_COLUMN_NAME); + addedPathColumn = true; + } this.columnNames = Collections.unmodifiableList(columnNames); } @@ -1141,6 +1154,30 @@ public List getColumnNameList() { return columnNames; } + + @Override + protected List loadColumnTypes(Columns columns) { + List types = new ArrayList(columns.getColumnCount() + (addedScoreColumn ? 1 : 0) + (addedPathColumn ? 1 : 0) ); + String stringtype = PropertyType.nameFromValue(PropertyType.STRING); + if (addedScoreColumn) types.add(0,stringtype); + if (addedPathColumn) types.add(0,stringtype); + + for (Column column : columns) { + String typeName = null; + Table table = schemata.getTable(column.getSelectorName()); + if (table != null) { + Schemata.Column typedColumn = table.getColumn(column.getPropertyName()); + typeName = typedColumn.getPropertyType(); + } + if (typeName == null) { + // Might be fabricated column, so just assume string ... + typeName = stringtype; + } + types.add(typeName); + } + + return types; + } /** * {@inheritDoc}