Better error message.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@632412 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2008-02-29 19:16:27 +00:00
parent 66d6230a41
commit 9ece24ade3
3 changed files with 45 additions and 2 deletions
openjpa-kernel/src/main
java/org/apache/openjpa/kernel/jpql
resources/org/apache/openjpa/kernel/jpql
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query

View File

@ -1355,8 +1355,8 @@ public class JPQLExpressionBuilder
else if (val.getMetaData() != null)
path = newPath(val, val.getMetaData());
else
throw parseException(EX_USER, "path-no-meta",
new Object[]{ assemble(node), null }, null);
throw parseException(EX_USER, "path-invalid",
new Object[]{ assemble(node), name }, null);
// walk through the children and assemble the path
boolean allowNull = !inner;

View File

@ -45,6 +45,9 @@ unknown-type: Cannot determine the type of field "{0}".
unexpected-var: The variable "{0}" was found where a constant or \
field value was expected.
path-no-meta: Attempt to query field "{0}" from non-entity class "{1}".
path-invalid: Attempt to query field "{0}" from non-entity variable "{1}". \
Perhaps you forgot to prefix the path in question with an identification \
variable from your FROM clause?
not-yet-supported: Expressions of type "{0}" are not yet supported.
bad-positional-parameter: The positional parameter "{0}" is invalid. \
Positional parameters must be integers greater than zero.

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.query;
import javax.persistence.Query;
import org.apache.openjpa.persistence.test.SingleEMTestCase;
public class TestJPQLWithoutIdentificationVariable extends SingleEMTestCase {
public void setUp() {
setUp(ManyOneEntity.class, ManyOneEntitySub.class);
}
public void testJPQLWithoutIdentificationVariable() {
try {
em.createQuery("select o from ManyOneEntity o " +
"where rel.name = :name").compile();
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains(
"Perhaps you forgot to prefix the path"));
}
}
}