diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index ffd9f4023..bd3356deb 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -1986,7 +1986,7 @@ public class DBDictionary // (SELECT 1 FROM TABLE t0 WHERE t0.ID = TABLE.ID); also, some // databases do not allow aliases in delete statements, which // also causes us to use a subselect - Set selectedTables = getSelectTableAliases(sel); + Collection selectedTables = getSelectTableAliases(sel); if (selectedTables.size() == 1 && supportsSubselect && allowsAliasInBulkClause) { SQLBuffer from; @@ -2070,14 +2070,8 @@ public class DBDictionary return sql; } - Set getSelectTableAliases(Select sel) { - Set result = new HashSet(); - List selects = sel.getIdentifierAliases(); - for (String s : selects) { - String tableAlias = s.substring(0, s.indexOf('.')); - result.add(tableAlias); - } - return result; + protected Collection getSelectTableAliases(Select sel) { + return sel.getTableAliases(); } protected SQLBuffer getDeleteTargets(Select sel) { diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java index a559f872d..093bd0228 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java @@ -24,6 +24,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; @@ -383,4 +387,15 @@ public class MySQLDictionary select += " " + hint; return select; } + + @Override + protected Collection getSelectTableAliases(Select sel) { + Set result = new HashSet(); + List selects = sel.getIdentifierAliases(); + for (String s : selects) { + String tableAlias = s.substring(0, s.indexOf('.')); + result.add(tableAlias); + } + return result; + } }