Query fixes.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@443170 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2006-09-14 00:05:16 +00:00
parent 913e54c93c
commit 72f7b6b963
5 changed files with 14 additions and 10 deletions

View File

@ -245,6 +245,13 @@ class PCPath
: _class.getPrimaryKeyColumns(); : _class.getPrimaryKeyColumns();
} }
public boolean isVariable() {
if (_actions == null)
return false;
Action action = (Action) _actions.getLast();
return action.op == Action.UNBOUND_VAR || action.op == Action.VAR;
}
public void get(FieldMetaData field, boolean nullTraversal) { public void get(FieldMetaData field, boolean nullTraversal) {
if (_actions == null) if (_actions == null)
_actions = new LinkedList(); _actions = new LinkedList();

View File

@ -660,8 +660,8 @@ public class MappingTool
ClassMapping mapping = repos.getMapping(cls, null, false); ClassMapping mapping = repos.getMapping(cls, null, false);
if (mapping != null) if (mapping != null)
return mapping; return mapping;
if (!validate || cls.isInterface() || if (!validate || cls.isInterface()
repos.getPersistenceAware(cls) != null) || repos.getPersistenceAware(cls) != null)
return null; return null;
throw new MetaDataException(_loc.get("no-meta", cls)); throw new MetaDataException(_loc.get("no-meta", cls));
} }

View File

@ -299,6 +299,10 @@ public class ExpressionStoreQuery
* Throw proper exception if given value is a collection/map/array. * Throw proper exception if given value is a collection/map/array.
*/ */
protected void assertNotContainer(Value val, StoreQuery q) { protected void assertNotContainer(Value val, StoreQuery q) {
// variables represent container elements, not the container itself
if (val.isVariable())
return;
Class type; Class type;
if (val instanceof Path) { if (val instanceof Path) {
FieldMetaData fmd = ((Path) val).last(); FieldMetaData fmd = ((Path) val).last();

View File

@ -1358,7 +1358,7 @@ class JPQLExpressionBuilder
// determind how to evauate a variabe // determind how to evauate a variabe
if (!val.isVariable()) if (!val.isVariable())
return val; return val;
else if (handleVar == VAR_PATH) else if (handleVar == VAR_PATH && !(val instanceof Path))
return newPath(val, val.getMetaData()); return newPath(val, val.getMetaData());
else if (handleVar == VAR_ERROR) else if (handleVar == VAR_ERROR)
throw parseException(EX_USER, "unexpected-var", throw parseException(EX_USER, "unexpected-var",

View File

@ -92,11 +92,6 @@ public class MetaDataRepository
private static final Localizer _loc = Localizer.forPackage private static final Localizer _loc = Localizer.forPackage
(MetaDataRepository.class); (MetaDataRepository.class);
// number of metadatas that have been registered thus far. This does not
// include dynamically-generated subclasses; it is just the count of
// user-created metadatas that were registered.
private int _count = 0;
// system sequence // system sequence
private SequenceMetaData _sysSeq = null; private SequenceMetaData _sysSeq = null;
@ -742,7 +737,6 @@ public class MetaDataRepository
if (_pawares.containsKey(cls)) if (_pawares.containsKey(cls))
throw new MetaDataException(_loc.get("pc-and-aware", cls)); throw new MetaDataException(_loc.get("pc-and-aware", cls));
_metas.put(cls, meta); _metas.put(cls, meta);
_count++;
} }
return meta; return meta;
} }
@ -863,7 +857,6 @@ public class MetaDataRepository
Class impl = (Class) _ifaces.remove(cls); Class impl = (Class) _ifaces.remove(cls);
if (impl != null) if (impl != null)
_metas.remove(impl); _metas.remove(impl);
_count--;
return true; return true;
} }
return false; return false;