openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marina Vatkina <Marina.Vatk...@Sun.COM>
Subject Re: Open JPA error-Could not locate metadata for the class using alias
Date Thu, 12 Apr 2007 00:39:10 GMT
Isn't it called an entity name in the JPA spec?

thanks,
-marina

Pinaki Poddar wrote:
> Persistent Java classes when used in Query use an alias (which is, be
> deafult, the unqualified name of the Java class). However, the alias is
> known to the runtime once the Java class is loaded in to JVM. When the
> very first JPA operation is a query and the persistence unit does not
> explictly declare all the persistent classes, the runtime is not yet
> aware of/registered the aliases. Hence the error.
> possible resolution:
> a) declare the persistent classes in <class> tag of persistence.xml
> b) load the class before using it -- e.g. call
> Class.forName("a.b.c.MyClass")
> 
>  
>  
> 
> 
> Pinaki Poddar
> BEA Systems
> 415.402.7317  
> 
> 
> -----Original Message-----
> From: saidulu chitipolu [mailto:csai_india@yahoo.co.in] 
> Sent: Wednesday, April 11, 2007 1:23 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: Open JPA error-Could not locate metadata for the class using
> alias 
> 
> Hi,
>   
>   I am trying to run standalone application access the database using
> spring ,openjpa.
>   
>   part of code in main method
>   
>   EntityManagerFactory factory =
> Persistence.createEntityManagerFactory("tsf");
>         EntityManager em =  factory.createEntityManager();
> 
>         System.out.println("------///// "+em);      
>        
>           
>         Query q = em.createQuery("select m from AbstractItemEntity m");
>         List<AbstractItemEntity> absEntity=q.getResultList();
>   
>   facing the problem at 
>         Query q = em.createQuery("select m from AbstractItemEntity m");
>   
>   we have persistance.xml and orm files.
>   
>   Log is as like below
>   your earliest suggetions are valuable
>   
>   110  INFO   [main] openjpa.Runtime - Starting OpenJPA 0.9.6-incubating
>   422  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.OracleDictionary".
>   766  INFO   [main] openjpa.MetaData - Found 10 classes with metadata
> in 31 milliseconds.
>   ------///// org.apache.openjpa.persistence.EntityManagerImpl@1c8b24d
>   Exception in thread "main" <4|true|0.9.6-incubating>
> org.apache.openjpa.persistence.ArgumentException: Could not locate
> metadata for the class using alias "AbstractItemEntity". Registered
> alias mappings: "{AbstractItemEntity=null}"
>       at
> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepositor
> y.java:343)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JP
> QLExpressionBuilder.java:164)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaDat
> a(JPQLExpressionBuilder.java:142)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaDat
> a(JPQLExpressionBuilder.java:211)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaDat
> a(JPQLExpressionBuilder.java:181)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JP
> QLExpressionBuilder.java:174)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$500(JPQLExpr
> essionBuilder.java:61)
>       at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate
> (JPQLExpressionBuilder.java:1657)
>       at
> org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:52)
>       at
> org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(E
> xpressionStoreQuery.java:145)
>       at
> org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:642)
>       at
> org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:
> 623)
>       at
> org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java
> :589)
>       at
> org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:65
> 1)
>       at
> org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1464)
>       at
> org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.j
> ava:120)
>       at
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:202)
>       at
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:25
> 1)
>       at com.symcor.sis.tecp.dao.ExecuteDB.main(ExecuteDB.java:35)
>   
>   
>        
> ---------------------------------
>  Check out what you're missing if you're not on Yahoo! Messenger 
> 
> Notice:  This email message, together with any attachments, may contain information 
of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,
 proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use
of the individual or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this by email and then
delete it.

Mime
View raw message