From bc63cd2e45b386040ea5e402d8ab6abd4d98c833 Mon Sep 17 00:00:00 2001 From: Enrico Olivelli Date: Thu, 23 Jul 2020 10:14:43 +0200 Subject: [PATCH] OPENJPA-2820 --- .../org/apache/openjpa/jdbc/identifier/DBIdentifier.java | 6 ++++-- .../apache/openjpa/lib/identifier/IdentifierImpl.java | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java index aa1f888c6..255784aed 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/identifier/DBIdentifier.java @@ -142,6 +142,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie if (DBIdentifierType.CONSTANT != getType() && DBIdentifierType.COLUMN_DEFINITION != getType()) { if (delimit) { name = Normalizer.delimit(name, true); + setNameDelimited(true); } else { name = Normalizer.normalizeString(name); } @@ -325,6 +326,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie sName.setNameInternal(getNameInternal()); sName.setType(getType()); sName.setIgnoreCase(getIgnoreCase()); + sName.setNameDelimited(isNameDelimited()); return sName; } @@ -859,7 +861,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie * @param name */ public static DBIdentifier removeDelimiters(DBIdentifier name) { - if (DBIdentifier.isNull(name)) { + if (DBIdentifier.isNull(name) || !name.isDelimited()) { return name; } if (!name.isDelimited()) { @@ -927,7 +929,7 @@ public class DBIdentifier extends IdentifierImpl implements Cloneable, Identifie if (DBIdentifier.isEmpty(this)) { return false; } - return Normalizer.isDelimited(getNameInternal()); + return isNameDelimited() || Normalizer.isDelimited(getNameInternal()); } /** diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierImpl.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierImpl.java index 3958cd3b1..99a636d45 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierImpl.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierImpl.java @@ -28,6 +28,7 @@ public class IdentifierImpl implements Identifier, Serializable { private static final long serialVersionUID = 1L; private String _name = null; + private boolean nameDelimited = false; protected IdentifierImpl() {} @@ -45,6 +46,14 @@ public class IdentifierImpl implements Identifier, Serializable { return _name; } + public boolean isNameDelimited() { + return nameDelimited; + } + + public void setNameDelimited(boolean nameDelimited) { + this.nameDelimited = nameDelimited; + } + @Override public String toString() { return getName();