diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java index e59a58252..05ebb4f23 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java @@ -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()); diff --git a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/exps/localizer.properties b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/exps/localizer.properties index 9a1d91c46..90d866d95 100644 --- a/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/exps/localizer.properties +++ b/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/exps/localizer.properties @@ -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. \ No newline at end of file diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java index 3464d1fe4..e0e23c166 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java @@ -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(); } diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties index 9a44d1c13..402336440 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties @@ -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. \ No newline at end of file