diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java index 007074f214..449d2fbab3 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/platform/database/OraclePlatform.java @@ -1119,8 +1119,16 @@ public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter prin printer.printString(primaryKeyFields); printer.printString(FROM_ID); printer.printString(queryString); - printer.printString(ORDER_BY_ID); - printer.printString(primaryKeyFields); + if (statement.hasOrderByExpressions()) { + try { + statement.printSQLOrderByClause(printer); + } catch (IOException exception) { + throw ValidationException.fileError(exception); + } + } else { + printer.printString(ORDER_BY_ID); + printer.printString(primaryKeyFields); + } printer.printString(END_FROM_ID); printer.printString(MAX_ROW); printer.printParameter(DatabaseCall.MAXROW_FIELD);