OPENJPA-1493: performance fix in getTableIndex

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@906614 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2010-02-04 19:38:27 +00:00
parent ec0eeedf35
commit 814fef0f7d
5 changed files with 36 additions and 3 deletions

View File

@ -166,7 +166,9 @@ public class SelectConstructor
subsel.setParent(sel, subquery.getCandidateAlias()); subsel.setParent(sel, subquery.getCandidateAlias());
} }
} }
if (HasContainsExpressionVisitor.hasContains(exps.filter)) {
sel.setHasSubselect(true);
}
initialize(sel, ctx, exps, state); initialize(sel, ctx, exps, state);
if (!sel.getAutoDistinct()) { if (!sel.getAutoDistinct()) {

View File

@ -443,6 +443,14 @@ public class LogicalUnion
throw new UnsupportedException(_loc.get("union-element")); throw new UnsupportedException(_loc.get("union-element"));
} }
public void setHasSubselect(boolean hasSub) {
sel.setHasSubselect(hasSub);
}
public boolean getHasSubselect() {
return sel.getHasSubselect();
}
public Select getFromSelect() { public Select getFromSelect() {
return null; return null;
} }

View File

@ -719,4 +719,18 @@ public interface Select
* @param schemaAlias * @param schemaAlias
*/ */
public void setSchemaAlias(String schemaAlias); public void setSchemaAlias(String schemaAlias);
/**
* Set the flag to indicate whether this Select has
* internally generated subselect
*/
public void setHasSubselect(boolean hasSub);
/**
* Return the flag to indicate whether this Select has
* internally generated subselect
* @return
*/
public boolean getHasSubselect();
} }

View File

@ -158,6 +158,7 @@ public class SelectImpl
private List _subsels = null; private List _subsels = null;
private SelectImpl _parent = null; private SelectImpl _parent = null;
private String _subPath = null; private String _subPath = null;
private boolean _hasSub = false;
// 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;
@ -559,6 +560,14 @@ public class SelectImpl
} }
} }
public void setHasSubselect(boolean hasSub) {
_hasSub = hasSub;
}
public boolean getHasSubselect() {
return _hasSub;
}
public Map getAliases() { public Map getAliases() {
return _aliases; return _aliases;
} }
@ -1990,8 +1999,9 @@ public class SelectImpl
if (pj != null && pj.path() != null) if (pj != null && pj.path() != null)
key = new Key(pj.path().toString(), key); key = new Key(pj.path().toString(), key);
if (_ctx != null && (_parent != null || _subsels != null)) if (_ctx != null && (_parent != null || _subsels != null || _hasSub)) {
i = findAliasForQuery(table, pj, key, create); i = findAliasForQuery(table, pj, key, create);
}
if (i != null) if (i != null)
return i.intValue(); return i.intValue();

View File

@ -1161,7 +1161,6 @@ public class TestTypesafeCriteria extends CriteriaTest {
executeAndCompareSQL(q, sql); executeAndCompareSQL(q, sql);
} }
@AllowFailure(message="The expected sql string is incorrect")
public void testValues5() { public void testValues5() {
String sql = "SELECT t0.name, t2.id, t2.label FROM CR_ITEM t0 " String sql = "SELECT t0.name, t2.id, t2.label FROM CR_ITEM t0 "
+ "INNER JOIN CR_ITEM_photos t1 ON t0.id = t1.ITEM_ID " + "INNER JOIN CR_ITEM_photos t1 ON t0.id = t1.ITEM_ID "