diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/jdbc/ERXSQLHelper.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/jdbc/ERXSQLHelper.java index ea99c418db2..4706abcfdd9 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/jdbc/ERXSQLHelper.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/jdbc/ERXSQLHelper.java @@ -1138,7 +1138,7 @@ public int rowCountForFetchSpecification(EOEditingContext ec, EOFetchSpecificati EOSQLExpression sqlExpression = sqlExpressionForFetchSpecification(ec, spec, 0, -1); String statement = sqlExpression.statement(); - int index = statement.toLowerCase().indexOf(" from "); + String listString = sqlExpression.listString(); String countExpression; if (spec.usesDistinct()) { @@ -1154,7 +1154,7 @@ public int rowCountForFetchSpecification(EOEditingContext ec, EOFetchSpecificati else { countExpression = "count(*) "; } - statement = (new StringBuilder()).append("select ").append(countExpression).append(statement.substring(index, statement.length())).toString(); + statement = statement.replace(listString, countExpression); sqlExpression.setStatement(statement); sql = statement; result = ERXEOAccessUtilities.rawRowsForSQLExpression(ec, model.name(), sqlExpression);