mirror of
https://github.com/apache/openjpa.git
synced 2025-02-22 10:07:07 +00:00
OPENJPA-51. Committing Catalina's patch. It passes against Derby in my environment as well.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@549882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
578c987ac4
commit
be91d228c5
@ -26,6 +26,7 @@ import java.sql.Statement;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.BitSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -158,6 +159,13 @@ public class SelectImpl
|
|||||||
// from select if this select selects from a tmp table created by another
|
// from select if this select selects from a tmp table created by another
|
||||||
private SelectImpl _from = null;
|
private SelectImpl _from = null;
|
||||||
private SelectImpl _outer = null;
|
private SelectImpl _outer = null;
|
||||||
|
|
||||||
|
// bitSet indicating if an alias is removed from parent select
|
||||||
|
// bit 0 : correspond to alias 0
|
||||||
|
// bit 1 : correspond to alias 1, etc.
|
||||||
|
// if the bit is set, the corresponding alias has been removed from parent
|
||||||
|
// and recorded under subselect.
|
||||||
|
private BitSet _removedAliasFromParent = new BitSet(16);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to return the proper table alias for the given alias index.
|
* Helper method to return the proper table alias for the given alias index.
|
||||||
@ -1488,8 +1496,13 @@ public class SelectImpl
|
|||||||
private void removeParentJoins(PathJoins pj) {
|
private void removeParentJoins(PathJoins pj) {
|
||||||
if (_parent == null)
|
if (_parent == null)
|
||||||
return;
|
return;
|
||||||
if (_parent._joins != null && !_parent._joins.isEmpty())
|
if (_parent._joins != null && !_parent._joins.isEmpty()) {
|
||||||
pj.joins().removeAll(_parent._joins.joins());
|
boolean removed = false;
|
||||||
|
if (!_removedAliasFromParent.isEmpty())
|
||||||
|
removed = _parent._joins.joins().removeAll(pj.joins());
|
||||||
|
if (!removed)
|
||||||
|
pj.joins().removeAll(_parent._joins.joins());
|
||||||
|
}
|
||||||
if (!pj.isEmpty())
|
if (!pj.isEmpty())
|
||||||
_parent.removeParentJoins(pj);
|
_parent.removeParentJoins(pj);
|
||||||
}
|
}
|
||||||
@ -1898,9 +1911,15 @@ public class SelectImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fromParent && _parent != null) {
|
if (!fromParent && _parent != null) {
|
||||||
alias = _parent.findAlias(table, key, false, this);
|
boolean removeAliasFromParent = key.toString().contains(":");
|
||||||
if (alias != null)
|
alias = _parent.findAlias(table, key, removeAliasFromParent, this);
|
||||||
|
if (alias != null) {
|
||||||
|
if (removeAliasFromParent) {
|
||||||
|
recordTableAlias(table, key, alias);
|
||||||
|
_removedAliasFromParent.set(alias.intValue());
|
||||||
|
}
|
||||||
return alias;
|
return alias;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_subsels != null) {
|
if (_subsels != null) {
|
||||||
SelectImpl sub;
|
SelectImpl sub;
|
||||||
@ -1914,9 +1933,11 @@ public class SelectImpl
|
|||||||
if (sub._tables != null)
|
if (sub._tables != null)
|
||||||
sub._tables.remove(alias);
|
sub._tables.remove(alias);
|
||||||
} else {
|
} else {
|
||||||
alias = sub.findAlias(table, key, true, null);
|
if (key instanceof String) {
|
||||||
if (!fromParent && alias != null)
|
alias = sub.findAlias(table, key, true, null);
|
||||||
recordTableAlias(table, key, alias);
|
if (!fromParent && alias != null)
|
||||||
|
recordTableAlias(table, key, alias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user