Generate informative error message when query fails due to wrong unbound variables

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@687122 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2008-08-19 18:42:26 +00:00
parent ff93b1d6e6
commit 4dd92231c5
4 changed files with 9 additions and 2 deletions

View File

@ -442,6 +442,9 @@ public class PCPath
// unbound vars are cross-joined to the candidate table
var = (Variable) action.data;
rel = (ClassMapping) var.getMetaData();
if (rel == null)
throw new IllegalArgumentException(_loc.get(
"invalid-unbound-var", var.getName()).toString());
pstate.joins = pstate.joins.setVariable(var.getName());
pstate.joins = pstate.joins.crossJoin(_candidate.getTable(),
rel.getTable());

View File

@ -23,6 +23,7 @@ no-in-mem: The filter listener "{0}" does not support in-memory operation; it \
const-only: The filter listener "{0}" requires a constant argument.
path-only: The target for filter listener "{0}" must be "this" or some \
field traversal to a related objects, such as "company.address".
no-col: The column "{0}" given to filter "{1}" doesn''t exist in the table \
no-col: The column "{0}" given to filter "{1}" does not exist in the table \
of the specified target.
cant-convert: Attempt to compare incompatible types "{0}" and "{1}".
invalid-unbound-var: Invalid unbound variable "{0}" in query.

View File

@ -854,7 +854,8 @@ public class QueryImpl
} catch (OpenJPAException ke) {
throw ke;
} catch (Exception e) {
throw new UserException(e);
throw new UserException(_loc.get("query-execution-error",
_query), e);
} finally {
_broker.endOperation();
}

View File

@ -403,3 +403,5 @@ fetch-configuration-stack-empty: Fetch configuration stack is empty.
gap-query-param: Parameter {1} for query "{0}" exceeds the number of {2} \
bound parameters with following values "{3}". This can happen if you have \
declared but missed to bind values for one or more parameters.
query-execution-error: Failed to execute query "{0}". Check the query syntax \
for correctness. See nested exception for details.