org.apache.openjpa.persistence.ArgumentException:解析查询过滤器时发生错误

时间:2012-07-24 13:41:36

标签: java persistence openjpa

I am getting this Exception in Open JPA.

<openjpa-1.2.3-SNAPSHOT-r422266:1295280 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "select a from Test a where a.something='D10584707'". Error message: The name "Test" is not a recogniz entity or identifier. Known entity names: []
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:156)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
[7/24/12 8:32:06:228 EDT] 00000015 SystemErr     R  at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)

这是我的持久性XML

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="MyDataSource">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>jdbc/MyDatasource</jta-data-source>
        <class>com.vo.Test</class>      
    </persistence-unit>

我已经将我的应用程序变形为Web App Archive并且它正在运行。但是,如果我像EJB3那样扭曲相同的应用程序那就是我有问题的地方。

我在WAS 7.0上运行

2 个答案:

答案 0 :(得分:1)

我解决了我的问题

我在Persistence.xml中缺少RuntimeUnenhancedClasses属性

现在我的持久性XML看起来像这样

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="MyDataSource">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <jta-data-source>jdbc/MyDatasource</jta-data-source>
    <class>com.vo.Test</class>      
    <properties>
    <property name="RuntimeUnenhancedClasses" value="supported"/>
    <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=INFO, Tool=INFO, SQL=TRACE" />
    </properties>
</persistence-unit>

答案 1 :(得分:1)

我遇到了同样的问题并通过更正jpql解决了问题。

是:SELECT c FROM NIMBUSOrganizationUnitEntityObject c WHERE **uuid** = :uuid

至:SELECT c FROM NIMBUSOrganizationUnitEntityObject c WHERE ***c.uuid*** = :uuid