From 1af78e4959eb5f24c0c55e66a50b646c8fb6e9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kraus?= Date: Fri, 22 Nov 2024 16:57:21 +0100 Subject: [PATCH] Issue #2301 - Sorting not honored with JPA and Oracle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Kraus --- .../platform/database/OraclePlatform.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/OraclePlatform.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/OraclePlatform.java index 02355de3a35..d47f517e6b5 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/OraclePlatform.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/OraclePlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2023 IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -1030,8 +1030,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);