mirror of https://github.com/apache/openjpa.git
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:
parent
66d6230a41
commit
9ece24ade3
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
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue