OPENJPA-459: fix bulkUpdate for DB2

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@886685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2009-12-03 06:36:36 +00:00
parent d488b471f5
commit 123e0b6120
2 changed files with 18 additions and 9 deletions

View File

@ -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<String> selectedTables = getSelectTableAliases(sel);
Collection<String> selectedTables = getSelectTableAliases(sel);
if (selectedTables.size() == 1 && supportsSubselect
&& allowsAliasInBulkClause) {
SQLBuffer from;
@ -2070,14 +2070,8 @@ public class DBDictionary
return sql;
}
Set<String> getSelectTableAliases(Select sel) {
Set<String> result = new HashSet<String>();
List<String> selects = sel.getIdentifierAliases();
for (String s : selects) {
String tableAlias = s.substring(0, s.indexOf('.'));
result.add(tableAlias);
}
return result;
protected Collection<String> getSelectTableAliases(Select sel) {
return sel.getTableAliases();
}
protected SQLBuffer getDeleteTargets(Select sel) {

View File

@ -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<String> getSelectTableAliases(Select sel) {
Set<String> result = new HashSet<String>();
List<String> selects = sel.getIdentifierAliases();
for (String s : selects) {
String tableAlias = s.substring(0, s.indexOf('.'));
result.add(tableAlias);
}
return result;
}
}