Total Pageviews

2011/08/12

The name "Ybdt010" is not a recognized entity or identifier

Problem
As I do query via OpenJPA in WAS(WebSphere Application Server), it complains this error message
 org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "select t from Ybdt010 t where t.emplCd = ?1". Error message: The name "Ybdt010" is not a recognized entity or identifier. Perhaps you meant Nigt010, which is a close match. Known entity names: [Nigw001, Nigt010, Nigt055, Nigt011, Nigt012, JUTSysParam, Nigt013, Nigt036, Nigt037, Nigt038, Nigt039, JUTMsg, Nigt080, Nigt081, Nigt082, Nigt040, Nigt063, Nigt041, Nigt042, Nigt020, Nigt064, Nigt021, Nigt043, Nigt044, Nigt088, Nigt001, Nigt045, Nigt005, Nigt006, Nigt007, Nigt008, JUTCode]   
 at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]   
 at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:177) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]   
 at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]   
 at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]   
 at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]   


Why it happened?
There was a problem if the first time you accessed an Entity type (ie. Ybdt010) via a Query instead of some other access.
It should be WebSphere's bug, need to install fixpack to fix this problem.

Solution
Here has a workaround solution to fix this problem. Before executing your query, you just insert something simple like...
 Ybdt010 ybdt010 = new Ybdt010();  


1 comment:

小池 said...

困擾了我好久的問題...原來只要new entity...
感謝大大分享!