From e9175a349dd010863e02d597a80f069cbc006cf0 Mon Sep 17 00:00:00 2001 From: Kalin Chan Date: Mon, 23 Sep 2024 12:28:07 +0100 Subject: [PATCH] fix malformed sql --- .../internal/expressions/FieldExpression.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/FieldExpression.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/FieldExpression.java index 53144f8785e..3b15c89f4fd 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/FieldExpression.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/FieldExpression.java @@ -292,7 +292,11 @@ public Expression rebuildOn(Expression newBase) { } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); - field.setTable(descriptor.getDefaultTable()); + DatabaseTable table = descriptor.getDefaultTable(); + if((field.getTableName().length() != 0) && descriptor.getTableNames().contains(field.getTableName())) { + table = descriptor.getTable(field.getTableName()); + } + field.setTable(table); } } FieldExpression expression = new FieldExpression(field, getBaseExpression().rebuildOn(newBase)); @@ -329,7 +333,11 @@ public Expression twistedForBaseAndContext(Expression newBase, Expression contex } if ((descriptor != null) && descriptor.hasTablePerClassPolicy()) { field = field.clone(); - field.setTable(descriptor.getDefaultTable()); + DatabaseTable table = descriptor.getDefaultTable(); + if((field.getTableName().length() != 0) && descriptor.getTableNames().contains(field.getTableName())) { + table = descriptor.getTable(field.getTableName()); + } + field.setTable(table); } } return twistedBase.getField(field);