You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by saidulu chitipolu <cs...@yahoo.co.in> on 2007/04/11 20:23:09 UTC

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(MetaDataRepository.java:343)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:164)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:142)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:211)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:181)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:174)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$500(JPQLExpressionBuilder.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(ExpressionStoreQuery.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:651)
      at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1464)
      at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:120)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:202)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:251)
      at com.symcor.sis.tecp.dao.ExecuteDB.main(ExecuteDB.java:35)
  
  
       
---------------------------------
 Check out what you're missing if you're not on Yahoo! Messenger 

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/11/07, saidulu chitipolu <cs...@yahoo.co.in> wrote:

>   your earliest suggetions are valuable

You may want to take a look at the following thread -
http://www.mail-archive.com/open-jpa-dev@incubator.apache.org/msg02770.html.

Make sure that your class is @Entity-annotated, PCEnhance it and put
the enhanced classes in the application classloader.

Consider sending the files - AbstractItemEntity.java and
persistence.xml and how you run the app - with javaagent or you
PCEnhance the entities.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Pinaki Poddar <pp...@bea.com>.
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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> Do you have an orm.xml (or another <mapping>.xml file) that might override
> some 
> information? Can it be that not all classes are on the classpath? Or can
> there 
> be another persistence.xml or orm.xml on the classpath that can affect the 
> results? As there are plenty of tests that test an entity that extend an 
> abstract entity, it's most probably something in your configuration that
> causes 
> the problem.
> 
> BTW, what kind of error do you get with Toplink?
> 

The reverse engineering has always generated JPA classes, so there is no
other type of persistence configuration file aside from the one
persistence.xml file. In there I swap the "provider" tag in order to enable
Toplink or OpenJPA. The properties section contains properties for both
engines. 

Toplink requires a primary key to be present in the @Entity class:

Entity class [class nl.reinders.bm.Relationcat] has no primary key
specified. It should define either an @Id, @EmbeddedId or an @IdClass.

One this the Toplink reported was very interesting in association with the
OpenJPA problem:

The alias name for the entity class [class nl.reinders.bm.Relationcat] is
being defaulted to: Relationcat.

Toplink decides to default an alias. The OpenJPA error is something about
not being able to find a alias. What is it with this alias and do I need to
specify it somewhere?
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10174890
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
Do you have an orm.xml (or another <mapping>.xml file) that might override some 
information? Can it be that not all classes are on the classpath? Or can there 
be another persistence.xml or orm.xml on the classpath that can affect the 
results? As there are plenty of tests that test an entity that extend an 
abstract entity, it's most probably something in your configuration that causes 
the problem.

BTW, what kind of error do you get with Toplink?

thanks,
-marina

tbee wrote:
> 
> 
> Marina Vatkina wrote:
> 
>>This is close to impossible as there are probably CTS tests that use an
>>@Entity
>>that extends another @Entity. Are you using JPA in an EE 5 container?
>>Otherwise 
>>you need to list all antities and mapped superclasses in your
>>persistence.xml.
>>
> 
> 
> I did'n't say this didn't work under OpenJPA, it doesn't work under Toplink.
> OpenJPA  continues to have the same exceptions as stated in the origin of
> this thread, so the @MappedSuperclass is not the reason.
> 
> JSE 1.6.0. 
> 
> All classes are listed in the persistance.xml (because it knows the class in
> question is persisted, but has trouble finding the metadata).
> 
> 

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
Oh, and don't worry about the lack of the DB. We can probably
forward-generate a schema for Derby or somesuch that is good enough for
the purposes of tracking down this problem.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Tuesday, April 24, 2007 11:24 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > Could you try out the almost-final OpenJPA 0.9.7 bits instead? The 
> > candidate (currently being voted on) is at 
> > 
> http://people.apache.org/~mikedd/staging-repository/org/apache/openjpa
> > /o 
> > 
> penjpa-project/0.9.7-incubating/openjpa-project-0.9.7-incubati
> ng-binary.
> > zip
> > 
> > If that doesn't work out, could you package up an example for us to 
> > try out against the latest code?
> > 
> 
> 47  reinders  INFO   [main] openjpa.Runtime - Starting OpenJPA
> 0.9.7-incubating
> 172  reinders  INFO   [main] openjpa.jdbc.JDBC - Using 
> dictionary class
> "org.apache.openjpa.jdbc.sql.InformixDictionary".
> Exception in thread "main" <0.9.7-incubating fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not 
> locate metadata for the class using alias "Article". 
> Registered alias mappings:
> "{Article=null}"
> 
> What I'm wondering about: when running under Toplink there is 
> an output "alias defaults to ....". Is there something that 
> Toplink assumes about this alias that actually should be 
> configured and where OpenJPA has problems with?
> 
> I can just "upload file" the example code? How to solve the 
> missing Informix database?
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10175078
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
> Understood. Right now I'm in the connection debate: toplink 
> cannot use less than 2, so each of my fat clients will have 3 
> open (1 it already has). So the decision is still open. It 
> appears that using a business model this way is not something 
> that is done often.

In what sense? In my experience, it's quite common to have some JDBC
code and some JPA code in non-trivial applications; connection
integration between the two different environments certainly is not
uncommon.

Note that if you plan to be accessing the same data in both places
(which is a bit less common), you should take care to flush your EM when
going from JPA to JDBC, and take corresponding precautions after going
from JDBC back to JPA work.

As David pointed out, if you're using table-based sequences in OpenJPA,
then, depending on your connection retain mode and flushing
characteristics, OpenJPA may need a second connection from time to time.
If you ensure that sufficient sequence values are available before doing
something that forces an EM to hold onto a connection, then you can
avoid this.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Thursday, April 26, 2007 10:17 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > FYI, once I commit a fix to OPENJPA-229, you'll be able to use the 
> > same class names once again. Sorry about that bug.
> > 
> 
> Understood. Right now I'm in the connection debate: toplink 
> cannot use less than 2, so each of my fat clients will have 3 
> open (1 it already has). So the decision is still open. It 
> appears that using a business model this way is not something 
> that is done often.
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10204857
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> FYI, once I commit a fix to OPENJPA-229, you'll be able to use the same
> class names once again. Sorry about that bug.
> 

Understood. Right now I'm in the connection debate: toplink cannot use less
than 2, so each of my fat clients will have 3 open (1 it already has). So
the decision is still open. It appears that using a business model this way
is not something that is done often.
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10204857
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
> Many thanks Patrick!

You're welcome. 

FYI, once I commit a fix to OPENJPA-229, you'll be able to use the same
class names once again. Sorry about that bug.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Thursday, April 26, 2007 1:54 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > I think that if you do 1, 2, 3, 5, and 6, you should be in 
> good shape.
> > 
> 
> This indeed seems to work!
> 
> BTW, Toplink just now also had its lazy loading issue solved: 
> turns out @MappedSuperclass classes must be listed in the 
> persistence.xml.  The solution actually was unexpected, it 
> suddenly worked, after you told me to do add them for the 
> OpenJPA issue. You've solved two issues in one go! :-) 
> 
> So now I'm suddenly from no working library to two. Now to 
> decide which one to use.
> 
> Many thanks Patrick!
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10196445
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
tbee wrote:
> 
> 
> Patrick Linskey wrote:
> 
>>I think that if you do 1, 2, 3, 5, and 6, you should be in good shape.
>>
> 
> 
> This indeed seems to work!
> 
> BTW, Toplink just now also had its lazy loading issue solved: turns out
> @MappedSuperclass classes must be listed in the persistence.xml. 

@MappedSuperclass must be listed (though providers can choose to help you there, 
the spec doesn't require them to do so) - see the spec section

6.2.1.6 mapping-file, jar-file, class, exclude-unlisted-classes

The following classes must be implicitly or explicitly denoted as managed 
persistence classes to be included within a persistence unit: entity classes; 
embeddable classes; mapped superclasses.

-marina

  The
> solution actually was unexpected, it suddenly worked, after you told me to
> do add them for the OpenJPA issue. You've solved two issues in one go! :-) 
> 
> So now I'm suddenly from no working library to two. Now to decide which one
> to use.
> 
> Many thanks Patrick!

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> I think that if you do 1, 2, 3, 5, and 6, you should be in good shape.
> 

This indeed seems to work!

BTW, Toplink just now also had its lazy loading issue solved: turns out
@MappedSuperclass classes must be listed in the persistence.xml.  The
solution actually was unexpected, it suddenly worked, after you told me to
do add them for the OpenJPA issue. You've solved two issues in one go! :-) 

So now I'm suddenly from no working library to two. Now to decide which one
to use.

Many thanks Patrick!
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10196445
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
> This is good to hear! (And also that the @MappedSuperclass 
> was the right way to go). I'm today not working on this 
> project, so I'll work through the changes tomorrow first thing! 

Cool. FWIW, I think that either @MappedSuperclass or @Entity could work
as an approach; switching to @Entity just seemed like more work given
how things were set up.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Wednesday, April 25, 2007 2:31 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > So, I got things working
> 
> This is good to hear! (And also that the @MappedSuperclass 
> was the right way to go). I'm today not working on this 
> project, so I'll work through the changes tomorrow first thing! 
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10177260
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> So, I got things working

This is good to hear! (And also that the @MappedSuperclass was the right way
to go). I'm today not working on this project, so I'll work through the
changes tomorrow first thing! 

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10177260
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
So, I got things working (well, to the point where the list.get(1) call
failed since my db was empty). I had to do the following to your code to
make things work:

1. changed back to @MappedSuperclass in generated dir

2. added all the superclasses to persistence.xml

3. commented out Zzzupdates -- GregorianCalendar is not a legal id type

4. renamed a bunch of columns and table names to not be reserved
keywords in Derby

5. fixed the GeneratedValue usage

6. renamed ....generated.Article to ....generated.ArticleBase

I think that if you do 1, 2, 3, 5, and 6, you should be in good shape.

FYI, I was getting a very cryptic error when the system had a
@MappedSuperclass called Article and an @Entity called Article. This is
a bug in OpenJPA -- mapped superclasses should not have aliases. You can
work around it by adding some postfix (as in ArticleBase) to all your
mapped superclasses. Certainly this is something that we should fix,
though.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Wednesday, April 25, 2007 1:06 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > Ok... the problem is that OpenJPA requires that you run the OpenJPA 
> > class enhancer over your classes (or run in a container environment 
> > such as an appserver or Spring, which can do 
> class-load-time processing).
> > 
> > The other problem is that the error message is really bad, 
> in that it 
> > doesn't suggest that as a cause, and in that the message 
> > stringification is deferred, causing the "Article=null" 
> negative-cache misdirection.
> > I've changed the error message and toString() logic.
> > 
> > Meanwhile, I got the following when running the enhancer on your
> > classes:
> > 
> > <0.0.0 fatal user error> org.apache.openjpa.util.MetaDataException:
> > "nl.reinders.bm.generated.License.iLicensenr" declares 
> generator name 
> > "licensenr", but uses the AUTO generation type.  The only valid 
> > generator names under AUTO are "uuid-hex" and "uuid-string".
> > 
> > I changed the @GeneratedValue annotation to specify that it's using 
> > the 'GenerationType.TABLE' strategy, but then I ran into 
> problems with 
> > classes that had compound identity but didn't specify an @IdClass.
> > 
> 
> 
> Ok, the first part I get; actually very logical. 
> 
> The generator I follow also, I should alter the RevEng to 
> generate type=table. Ok. But the compound identity I'm not 
> quite following. If all is well then I should be generating 
> "*PK.java" classes for tables with more than one field in the 
> PK and the corresponding @IdClass. Maybe the quick change to 
> "@Entity extends @Entity" has a bug, now that I think of it, 
> the @IdClass may refer to a PK class that actually is in the 
> generated package.
> Could you elaborate?
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10176178
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
> Could you elaborate?

You should put the @IdClass annotation in the same class as the @Id
fields are declared. So, in your example, in the @MappedSuperclass or
@Entity.

FYI, I just switched your classes back to using @MappedSuperclass -- the
subtypes were specified to use single-table inheritance, and table names
were also specified in the mapped superclasses, causing a mapping error.
I've had to make a couple of other changes to get things running; I'll
send more info soon.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Wednesday, April 25, 2007 1:06 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > Ok... the problem is that OpenJPA requires that you run the OpenJPA 
> > class enhancer over your classes (or run in a container environment 
> > such as an appserver or Spring, which can do 
> class-load-time processing).
> > 
> > The other problem is that the error message is really bad, 
> in that it 
> > doesn't suggest that as a cause, and in that the message 
> > stringification is deferred, causing the "Article=null" 
> negative-cache misdirection.
> > I've changed the error message and toString() logic.
> > 
> > Meanwhile, I got the following when running the enhancer on your
> > classes:
> > 
> > <0.0.0 fatal user error> org.apache.openjpa.util.MetaDataException:
> > "nl.reinders.bm.generated.License.iLicensenr" declares 
> generator name 
> > "licensenr", but uses the AUTO generation type.  The only valid 
> > generator names under AUTO are "uuid-hex" and "uuid-string".
> > 
> > I changed the @GeneratedValue annotation to specify that it's using 
> > the 'GenerationType.TABLE' strategy, but then I ran into 
> problems with 
> > classes that had compound identity but didn't specify an @IdClass.
> > 
> 
> 
> Ok, the first part I get; actually very logical. 
> 
> The generator I follow also, I should alter the RevEng to 
> generate type=table. Ok. But the compound identity I'm not 
> quite following. If all is well then I should be generating 
> "*PK.java" classes for tables with more than one field in the 
> PK and the corresponding @IdClass. Maybe the quick change to 
> "@Entity extends @Entity" has a bug, now that I think of it, 
> the @IdClass may refer to a PK class that actually is in the 
> generated package.
> Could you elaborate?
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10176178
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> Ok... the problem is that OpenJPA requires that you run the OpenJPA
> class enhancer over your classes (or run in a container environment such
> as an appserver or Spring, which can do class-load-time processing).
> 
> The other problem is that the error message is really bad, in that it
> doesn't suggest that as a cause, and in that the message stringification
> is deferred, causing the "Article=null" negative-cache misdirection.
> I've changed the error message and toString() logic.
> 
> Meanwhile, I got the following when running the enhancer on your
> classes:
> 
> <0.0.0 fatal user error> org.apache.openjpa.util.MetaDataException:
> "nl.reinders.bm.generated.License.iLicensenr" declares generator name
> "licensenr", but uses the AUTO generation type.  The only valid
> generator names under AUTO are "uuid-hex" and "uuid-string". 
> 
> I changed the @GeneratedValue annotation to specify that it's using the
> 'GenerationType.TABLE' strategy, but then I ran into problems with
> classes that had compound identity but didn't specify an @IdClass.
> 


Ok, the first part I get; actually very logical. 

The generator I follow also, I should alter the RevEng to generate
type=table. Ok. But the compound identity I'm not quite following. If all is
well then I should be generating "*PK.java" classes for tables with more
than one field in the PK and the corresponding @IdClass. Maybe the quick
change to "@Entity extends @Entity" has a bug, now that I think of it, the
@IdClass may refer to a PK class that actually is in the generated package.
Could you elaborate?

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10176178
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
Ok... the problem is that OpenJPA requires that you run the OpenJPA
class enhancer over your classes (or run in a container environment such
as an appserver or Spring, which can do class-load-time processing).

The other problem is that the error message is really bad, in that it
doesn't suggest that as a cause, and in that the message stringification
is deferred, causing the "Article=null" negative-cache misdirection.
I've changed the error message and toString() logic.

Meanwhile, I got the following when running the enhancer on your
classes:

<0.0.0 fatal user error> org.apache.openjpa.util.MetaDataException:
"nl.reinders.bm.generated.License.iLicensenr" declares generator name
"licensenr", but uses the AUTO generation type.  The only valid
generator names under AUTO are "uuid-hex" and "uuid-string". 

I changed the @GeneratedValue annotation to specify that it's using the
'GenerationType.TABLE' strategy, but then I ran into problems with
classes that had compound identity but didn't specify an @IdClass.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Wednesday, April 25, 2007 12:03 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > I don't think that uploading to this mailing list works; 
> the easiest 
> > thing to do is to create a JIRA issue and attach the jar / 
> zip of the 
> > problem there. If you'd rather not create a JIRA account, 
> you can send 
> > the code to pcl at apache dot org, and I'll attach it to a 
> new issue 
> > for the group's perusal.
> > 
> 
> Alrighty then: OPENJPA-228
> 
> This is the BM archive with "@Entity extends @Entity" instead 
> of "@Entity extends @MappedSuperclass". But I do not believe 
> OpenJPA gets to that part, because that actually does not 
> make a difference.
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10175457
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> I don't see nl/reinders/bm/generated/... classes listed in
> persistence.xml. 
> While the provider might find that a superclass is an entity, for a spec 
> compliant application, you must list all of them.
> 

Ok...

		<class>nl.reinders.bm.Contract</class>
		...
		<class>nl.reinders.bm.Websort</class>

		<class>nl.reinders.bm.generated.Contract</class>
		...
		<class>nl.reinders.bm.generated.Websort</class>


No difference:

47  reinders  INFO   [main] openjpa.Runtime - Starting OpenJPA
0.9.7-incubating
156  reinders  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
"org.apache.openjpa.jdbc.sql.InformixDictionary".
Exception in thread "main" <0.9.7-incubating fatal user error>
org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
for the class using alias "Article". Registered alias mappings:
"{Article=null}"
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:348)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:167)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:145)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:214)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:184)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:177)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$500(JPQLExpressionBuilder.java:64)
	at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1671)
	at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:55)
	at
org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:148)
	at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:649)
	at
org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:630)
	at
org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:596)
	at
org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:658)
	at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1483)
	at
org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
	at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:219)
	at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:269)
	at nl.reinders.bm.BMTestOpenJPA.main(BMTestOpenJPA.java:41)


How about there being two classes with the same shortname?

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10175675
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
Tom,

I don't see nl/reinders/bm/generated/... classes listed in persistence.xml. 
While the provider might find that a superclass is an entity, for a spec 
compliant application, you must list all of them.

-marina

tbee wrote:
> 
> 
> Patrick Linskey wrote:
> 
>>I don't think that uploading to this mailing list works; the easiest
>>thing to do is to create a JIRA issue and attach the jar / zip of the
>>problem there. If you'd rather not create a JIRA account, you can send
>>the code to pcl at apache dot org, and I'll attach it to a new issue for
>>the group's perusal.
>>
> 
> 
> Alrighty then: OPENJPA-228
> 
> This is the BM archive with "@Entity extends @Entity" instead of "@Entity
> extends @MappedSuperclass". But I do not believe OpenJPA gets to that part,
> because that actually does not make a difference.
> 


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> I don't think that uploading to this mailing list works; the easiest
> thing to do is to create a JIRA issue and attach the jar / zip of the
> problem there. If you'd rather not create a JIRA account, you can send
> the code to pcl at apache dot org, and I'll attach it to a new issue for
> the group's perusal.
> 

Alrighty then: OPENJPA-228

This is the BM archive with "@Entity extends @Entity" instead of "@Entity
extends @MappedSuperclass". But I do not believe OpenJPA gets to that part,
because that actually does not make a difference.

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10175457
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
> What I'm wondering about: when running under Toplink there is 
> an output "alias defaults to ....". Is there something that 
> Toplink assumes about this alias that actually should be 
> configured and where OpenJPA has problems with?

No... the alias should default to the short name of the class; that
behavior is defined in the spec.

> I can just "upload file" the example code? How to solve the 
> missing Informix database?

I don't think that uploading to this mailing list works; the easiest
thing to do is to create a JIRA issue and attach the jar / zip of the
problem there. If you'd rather not create a JIRA account, you can send
the code to pcl at apache dot org, and I'll attach it to a new issue for
the group's perusal.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Tuesday, April 24, 2007 11:24 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > Could you try out the almost-final OpenJPA 0.9.7 bits instead? The 
> > candidate (currently being voted on) is at 
> > 
> http://people.apache.org/~mikedd/staging-repository/org/apache/openjpa
> > /o 
> > 
> penjpa-project/0.9.7-incubating/openjpa-project-0.9.7-incubati
> ng-binary.
> > zip
> > 
> > If that doesn't work out, could you package up an example for us to 
> > try out against the latest code?
> > 
> 
> 47  reinders  INFO   [main] openjpa.Runtime - Starting OpenJPA
> 0.9.7-incubating
> 172  reinders  INFO   [main] openjpa.jdbc.JDBC - Using 
> dictionary class
> "org.apache.openjpa.jdbc.sql.InformixDictionary".
> Exception in thread "main" <0.9.7-incubating fatal user error>
> org.apache.openjpa.persistence.ArgumentException: Could not 
> locate metadata for the class using alias "Article". 
> Registered alias mappings:
> "{Article=null}"
> 
> What I'm wondering about: when running under Toplink there is 
> an output "alias defaults to ....". Is there something that 
> Toplink assumes about this alias that actually should be 
> configured and where OpenJPA has problems with?
> 
> I can just "upload file" the example code? How to solve the 
> missing Informix database?
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10175078
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> Could you try out the almost-final OpenJPA 0.9.7 bits instead? The
> candidate (currently being voted on) is at
> http://people.apache.org/~mikedd/staging-repository/org/apache/openjpa/o
> penjpa-project/0.9.7-incubating/openjpa-project-0.9.7-incubating-binary.
> zip
> 
> If that doesn't work out, could you package up an example for us to try
> out against the latest code?
> 

47  reinders  INFO   [main] openjpa.Runtime - Starting OpenJPA
0.9.7-incubating
172  reinders  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
"org.apache.openjpa.jdbc.sql.InformixDictionary".
Exception in thread "main" <0.9.7-incubating fatal user error>
org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
for the class using alias "Article". Registered alias mappings:
"{Article=null}"

What I'm wondering about: when running under Toplink there is an output
"alias defaults to ....". Is there something that Toplink assumes about this
alias that actually should be configured and where OpenJPA has problems
with?

I can just "upload file" the example code? How to solve the missing Informix
database?
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10175078
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
I think that there were some JIRA issues with aliases in 0.9.6. I
thought that most of them had to do with orm.xml processing, but maybe
some of them were more low-level than that.

Could you try out the almost-final OpenJPA 0.9.7 bits instead? The
candidate (currently being voted on) is at
http://people.apache.org/~mikedd/staging-repository/org/apache/openjpa/o
penjpa-project/0.9.7-incubating/openjpa-project-0.9.7-incubating-binary.
zip

If that doesn't work out, could you package up an example for us to try
out against the latest code?

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Tuesday, April 24, 2007 11:04 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Patrick Linskey wrote:
> > 
> > What's the OpenJPA version in question?
> > 
> 
> 
> openjpa-project-0.9.6-incubating-binary
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10174891
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> What's the OpenJPA version in question?
> 


openjpa-project-0.9.6-incubating-binary
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10174891
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
What's the OpenJPA version in question?

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Tuesday, April 24, 2007 10:20 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Re: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Marina Vatkina wrote:
> > 
> > This is close to impossible as there are probably CTS tests 
> that use 
> > an @Entity that extends another @Entity. Are you using JPA 
> in an EE 5 
> > container?
> > Otherwise
> > you need to list all antities and mapped superclasses in your 
> > persistence.xml.
> > 
> 
> I did'n't say this didn't work under OpenJPA, it doesn't work 
> under Toplink.
> OpenJPA  continues to have the same exceptions as stated in 
> the origin of this thread, so the @MappedSuperclass is not the reason.
> 
> JSE 1.6.0. 
> 
> All classes are listed in the persistance.xml (because it 
> knows the class in question is persisted, but has trouble 
> finding the metadata).
> 
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10165609
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> This is close to impossible as there are probably CTS tests that use an
> @Entity
> that extends another @Entity. Are you using JPA in an EE 5 container?
> Otherwise 
> you need to list all antities and mapped superclasses in your
> persistence.xml.
> 

I did'n't say this didn't work under OpenJPA, it doesn't work under Toplink.
OpenJPA  continues to have the same exceptions as stated in the origin of
this thread, so the @MappedSuperclass is not the reason.

JSE 1.6.0. 

All classes are listed in the persistance.xml (because it knows the class in
question is persisted, but has trouble finding the metadata).


-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10165609
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
+1. I imagine that the @Entity-extends-@Entity failure in Toplink was
due to mapping specifications or something that Toplink didn't support.

If you could attach a small domain that produces the errors, that would
help make the discussion more concrete.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: Craig.Russell@Sun.COM [mailto:Craig.Russell@Sun.COM] 
> Sent: Tuesday, April 24, 2007 9:40 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Re: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> Hi tbee,
> 
> I've only seen bits and pieces of this issue scattered 
> through a dozen emails. I understand vaguely that you're 
> trying to separate the persistent field definition from the 
> behavior, but can't really understand how you're trying to do it.
> 
> Would it be possible for you to post a complete (simple) 
> example that shows what you are trying to do, including both 
> the classes and the database schema, for both sides of the 
> relationship.
> 
> Thanks,
> 
> Craig
> 
> On Apr 24, 2007, at 9:21 AM, Marina Vatkina wrote:
> 
> > tbee wrote:
> >> Marina Vatkina wrote:
> >>> I didn't suggest to remove the existing @Entity 
> annotation - what I 
> >>> suggested was to change the @MappedSuperclass to be an @Entity,
> >>> *and* make it
> >>> *abstract*.
> >>> The latter will mean that you'll never get its instances back.
> >>>
> >> I've tested this, but OpenJPA still has the same error:
> >> org.apache.openjpa.persistence.ArgumentException: Could not locate 
> >> metadata for the class using alias "Article". Registered alias 
> >> mappings:
> >> "{Article=null}"
> >> As a comparison, Toplink does not accept this approach at all 
> >> (@Entity extends @Entity). It requires the superclass to be 
> >> MappedSuperclass (@Entity extends @MappedSuperclass).
> >
> > This is close to impossible as there are probably CTS tests 
> that use 
> > an @Entity that extends another @Entity. Are you using JPA 
> in an EE 5 
> > container? Otherwise you need to list all antities and mapped 
> > superclasses in your persistence.xml.
> >
> > -marina
> >
> >> So unforntunately this approach seems to be a dead end.
> >
> 
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp!
> 
> 

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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi tbee,

I've only seen bits and pieces of this issue scattered through a  
dozen emails. I understand vaguely that you're trying to separate the  
persistent field definition from the behavior, but can't really  
understand how you're trying to do it.

Would it be possible for you to post a complete (simple) example that  
shows what you are trying to do, including both the classes and the  
database schema, for both sides of the relationship.

Thanks,

Craig

On Apr 24, 2007, at 9:21 AM, Marina Vatkina wrote:

> tbee wrote:
>> Marina Vatkina wrote:
>>> I didn't suggest to remove the existing @Entity annotation - what I
>>> suggested was to change the @MappedSuperclass to be an @Entity,  
>>> *and* make it
>>> *abstract*.
>>> The latter will mean that you'll never get its instances back.
>>>
>> I've tested this, but OpenJPA still has the same error:
>> org.apache.openjpa.persistence.ArgumentException: Could not locate  
>> metadata
>> for the class using alias "Article". Registered alias mappings:
>> "{Article=null}"
>> As a comparison, Toplink does not accept this approach at all  
>> (@Entity
>> extends @Entity). It requires the superclass to be  
>> MappedSuperclass (@Entity
>> extends @MappedSuperclass).
>
> This is close to impossible as there are probably CTS tests that  
> use an @Entity
> that extends another @Entity. Are you using JPA in an EE 5  
> container? Otherwise you need to list all antities and mapped  
> superclasses in your persistence.xml.
>
> -marina
>
>> So unforntunately this approach seems to be a dead end.
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
tbee wrote:
> 
> 
> Marina Vatkina wrote:
> 
>>I didn't suggest to remove the existing @Entity annotation - what I
>>suggested 
>>was to change the @MappedSuperclass to be an @Entity, *and* make it
>>*abstract*.
>>The latter will mean that you'll never get its instances back.
>>
> 
> 
> I've tested this, but OpenJPA still has the same error:
> 
> org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
> for the class using alias "Article". Registered alias mappings:
> "{Article=null}"
> 
> As a comparison, Toplink does not accept this approach at all (@Entity
> extends @Entity). It requires the superclass to be MappedSuperclass (@Entity
> extends @MappedSuperclass).

This is close to impossible as there are probably CTS tests that use an @Entity
that extends another @Entity. Are you using JPA in an EE 5 container? Otherwise 
you need to list all antities and mapped superclasses in your persistence.xml.

-marina

> 
> So unforntunately this approach seems to be a dead end. 
> 
> 


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> I didn't suggest to remove the existing @Entity annotation - what I
> suggested 
> was to change the @MappedSuperclass to be an @Entity, *and* make it
> *abstract*.
> The latter will mean that you'll never get its instances back.
> 

I've tested this, but OpenJPA still has the same error:

org.apache.openjpa.persistence.ArgumentException: Could not locate metadata
for the class using alias "Article". Registered alias mappings:
"{Article=null}"

As a comparison, Toplink does not accept this approach at all (@Entity
extends @Entity). It requires the superclass to be MappedSuperclass (@Entity
extends @MappedSuperclass).

So unforntunately this approach seems to be a dead end. 


-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10155865
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> I didn't suggest to remove the existing @Entity annotation - what I
> suggested 
> was to change the @MappedSuperclass to be an @Entity, *and* make it
> *abstract*.
> The latter will mean that you'll never get its instances back.
> 

Ok, do you mean:

 @Entity
 class Article extends Article2
 
 @Entity
abstract class Article2
   @ManyToOne
   private Manufacturer; // note: not Manufacturer2!!


Well, I'll give it a spin on, ah, tuesday. If it works and is better
supported by frameworks, I'm all excited.


-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10113798
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
tbee wrote:
>>How can you define relationships in the mapped superclass that are
> 
> *specified* 
> 
>>in terms of the entities?
> 
> 
> Quite simple:
> 
> @Entity
> class Article extends Article2
> 
> @MappedSuperclass
> class Article2
>   @ManyToOne
>   private Manufacturer; // note: not Manufacturer2!!
> 
> 
> 
>>You can always change the annotation from @MappedSuperclass to an @Entity
>>and 
>>make the class abstract.
> 
> 
> I do not believe that will work. Aim of the game is that the class returned
> by queries, etc, must be the class containing all the business logic. So
> AFAIK that must be the @Entity. That class must extended a class that
> contains the reversed engineered mappings.

I didn't suggest to remove the existing @Entity annotation - what I suggested 
was to change the @MappedSuperclass to be an @Entity, *and* make it *abstract*.
The latter will mean that you'll never get its instances back.


> 
> 
> 
>>They might, but that would be beyond the spec and as such not a portable
>>solution.
> 
> 
> If this is beyond the spec: what is @MappedSuperclass intended for?

To share common fields between several entities without sharing the table that 
they are mapped to. It's behavior is closer to that of an embeddable class and 
the first version of the name that the expert group discussed had an 
'embeddable' in its name (see A.4 Changes Since Public Draft "Renamed 
EmbeddableSuperclass as MappedSuperclass.")

Regards,
-marina

> 

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.
> How can you define relationships in the mapped superclass that are
*specified* 
> in terms of the entities?

Quite simple:

@Entity
class Article extends Article2

@MappedSuperclass
class Article2
  @ManyToOne
  private Manufacturer; // note: not Manufacturer2!!


> You can always change the annotation from @MappedSuperclass to an @Entity
> and 
> make the class abstract.

I do not believe that will work. Aim of the game is that the class returned
by queries, etc, must be the class containing all the business logic. So
AFAIK that must be the @Entity. That class must extended a class that
contains the reversed engineered mappings.


> They might, but that would be beyond the spec and as such not a portable
> solution.

If this is beyond the spec: what is @MappedSuperclass intended for?

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10110227
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
tbee wrote:
> 
> 
> Marina Vatkina wrote:
> 
>>The spec defines the following limitations of a MappedSuperclass:
>>
>>2.1.9.2 Mapped Superclasses
>>...
>>A mapped superclass, unlike an entity, is not queryable and cannot be
>>passed as 
>>an argument to EntityManager or Query operations. A mapped superclass
>>cannot be 
>>the target of a persistent relationship.
>>
>>
> 
> 
> Correct. It is not. All relations refer to the inheriting classes. So even
> if the relation is defined in the @MappedSuperclass, the result of the
> relation are the actual @Entity.

How can you define relationships in the mapped superclass that are *specified* 
in terms of the entities?

> 
> I believe this approach is invaluable if you want to save coding time: my
> reverse engineering class generates a JPA MappedSuperclass based on the
> database and the actual Entity class only contains the JPA table annotation
> and all business logic.

You can always change the annotation from @MappedSuperclass to an @Entity and 
make the class abstract.

> 
> Hibernate also has some trouble with this concept, but Toplink works fine. I
> have an issue with lazy loading there, but the approach is perfect.

They might, but that would be beyond the spec and as such not a portable solution.

> 

RE: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Patrick Linskey wrote:
> 
> Note that in OpenJPA, you could fully specify all your relations as
> relations between the abstrat entity classes or mapped superclasses (so
> AbstractPerson would have a reference to AbstractAddress, etc.) and then
> narrow the types of the relations in the subclasses. This would allow
> you to create something where your reverse-engineered classes fully
> compiled on their own, and also would result in an efficient schema with
> direct relations between the concrete subtypes.
> 


Interesting. A query would then still return the "actual" (extending) class
containing the business logic?

How would one declare the narrowing?

Tom
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10165713
Sent from the open-jpa-dev mailing list archive at Nabble.com.


RE: Open JPA error-Could not locate metadata for the class using alias

Posted by Patrick Linskey <pl...@bea.com>.
Note that in OpenJPA, you could fully specify all your relations as
relations between the abstrat entity classes or mapped superclasses (so
AbstractPerson would have a reference to AbstractAddress, etc.) and then
narrow the types of the relations in the subclasses. This would allow
you to create something where your reverse-engineered classes fully
compiled on their own, and also would result in an efficient schema with
direct relations between the concrete subtypes.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc.
_______________________________________________________________________
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. 

> -----Original Message-----
> From: tbee [mailto:tbee@tbee.org] 
> Sent: Friday, April 20, 2007 10:20 AM
> To: open-jpa-dev@incubator.apache.org
> Subject: Re: Open JPA error-Could not locate metadata for the 
> class using alias
> 
> 
> 
> 
> Marina Vatkina wrote:
> > 
> > The spec defines the following limitations of a MappedSuperclass:
> > 
> > 2.1.9.2 Mapped Superclasses
> > ...
> > A mapped superclass, unlike an entity, is not queryable and 
> cannot be 
> > passed as an argument to EntityManager or Query operations. 
> A mapped 
> > superclass cannot be the target of a persistent relationship.
> > 
> > 
> 
> Correct. It is not. All relations refer to the inheriting 
> classes. So even if the relation is defined in the 
> @MappedSuperclass, the result of the relation are the actual @Entity.
> 
> I believe this approach is invaluable if you want to save 
> coding time: my reverse engineering class generates a JPA 
> MappedSuperclass based on the database and the actual Entity 
> class only contains the JPA table annotation and all business logic.
> 
> Hibernate also has some trouble with this concept, but 
> Toplink works fine. I have an issue with lazy loading there, 
> but the approach is perfect.
> 
> --
> View this message in context: 
> http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata
> -for-the-class-using-alias-tf3561516.html#a10106645
> Sent from the open-jpa-dev mailing list archive at Nabble.com.
> 
> 

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.

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Marina Vatkina wrote:
> 
> The spec defines the following limitations of a MappedSuperclass:
> 
> 2.1.9.2 Mapped Superclasses
> ...
> A mapped superclass, unlike an entity, is not queryable and cannot be
> passed as 
> an argument to EntityManager or Query operations. A mapped superclass
> cannot be 
> the target of a persistent relationship.
> 
> 

Correct. It is not. All relations refer to the inheriting classes. So even
if the relation is defined in the @MappedSuperclass, the result of the
relation are the actual @Entity.

I believe this approach is invaluable if you want to save coding time: my
reverse engineering class generates a JPA MappedSuperclass based on the
database and the actual Entity class only contains the JPA table annotation
and all business logic.

Hibernate also has some trouble with this concept, but Toplink works fine. I
have an issue with lazy loading there, but the approach is perfect.

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10106645
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Marina Vatkina <Ma...@Sun.COM>.
The spec defines the following limitations of a MappedSuperclass:

2.1.9.2 Mapped Superclasses
...
A mapped superclass, unlike an entity, is not queryable and cannot be passed as 
an argument to EntityManager or Query operations. A mapped superclass cannot be 
the target of a persistent relationship.

-marina

tbee wrote:
> 
> 
> tbee wrote:
> 
>>
>>
>>Jacek Laskowski-4 wrote:
>>
>>>So I read it that you're relying "on the other mechanisms" TopLink JPA
>>>provides.
>>>
>>
>>Ah, no, all classes are defined in the persistence.xml. In fact I turned
>>autodetection explicitely off when I was trying Hibernate (OpenJPA is
>>attempt 3); my persistent classes are reverse engineered from the DB and
>>some metatables generate classes that cause trouble, and I explicitely
>>make them non-persistent by removing them from the <class> list. Sorry.
>>
> 
> 
> Is it possible this has to do with the way I've setup the entity classes?
> What I do is have an @Entity class without any fields and it extends a
> @MappedSuperclass which is generated from the DB and where all the actual
> fields are declared.
> 
> package nl.reinders.bm;
> @Entity
> @Table(name="article")
> public class Article extends nl.reinders.bm.generated.Article
> {
> 	... almost empty...
> }
> 
> 
> package nl.reinders.bm.generated;
> @MappedSuperclass
> public class Article
> {
> 	@OneToMany(mappedBy = "iArticle"...
> 	...
> 	@Column(name="description")
> 	private String iDescription;
> 	....
> }
> 


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/20/07, tbee <tb...@tbee.org> wrote:

> <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="reinders">
>
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>
>                 <class>nl.reinders.bm.Contract</class>
> ....50x
>                 <class>nl.reinders.bm.Websort</class>
>
>                 <properties>
>             <property name="openjpa.ConnectionDriverName"
> value="com.informix.jdbc.IfxDriver"/>
>             <property name="openjpa.ConnectionURL"
> value="jdbc:informix-sqli://...;DB_LOCALE=en_us.utf8"/>
>             <property name="openjpa.ConnectionUserName" value="user"/>
>             <property name="openjpa.ConnectionPassword" value="password"/>
>                 </properties>
>         </persistence-unit>
> </persistence>

Nothing relevant comes to my mind. Could you verify that your
application work when you add Class.forName() with each and every
entity after creating a PU, but before executing any queries? If that
should work, it might mean it's a OpenJPA bug.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Jacek Laskowski-4 wrote:
> 
> I've never used @MappedSuperclass so I can't comment on it. Could you
> present your persistence.xml (and orm.xml if used)?
> 

Sure!

<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="reinders">
		
	
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

		<class>nl.reinders.bm.Contract</class>
....50x
		<class>nl.reinders.bm.Websort</class>

		<properties>
            <property name="openjpa.ConnectionDriverName"
value="com.informix.jdbc.IfxDriver"/>
            <property name="openjpa.ConnectionURL"
value="jdbc:informix-sqli://...;DB_LOCALE=en_us.utf8"/>
            <property name="openjpa.ConnectionUserName" value="user"/>
            <property name="openjpa.ConnectionPassword" value="password"/>
		</properties>
	</persistence-unit>
</persistence>
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10103040
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/20/07, tbee <tb...@tbee.org> wrote:

> Is it possible this has to do with the way I've setup the entity classes?
> What I do is have an @Entity class without any fields and it extends a
> @MappedSuperclass which is generated from the DB and where all the actual
> fields are declared.

I've never used @MappedSuperclass so I can't comment on it. Could you
present your persistence.xml (and orm.xml if used)?

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


tbee wrote:
> 
> 
> 
> Jacek Laskowski-4 wrote:
>> 
>> So I read it that you're relying "on the other mechanisms" TopLink JPA
>> provides.
>> 
> 
> Ah, no, all classes are defined in the persistence.xml. In fact I turned
> autodetection explicitely off when I was trying Hibernate (OpenJPA is
> attempt 3); my persistent classes are reverse engineered from the DB and
> some metatables generate classes that cause trouble, and I explicitely
> make them non-persistent by removing them from the <class> list. Sorry.
> 

Is it possible this has to do with the way I've setup the entity classes?
What I do is have an @Entity class without any fields and it extends a
@MappedSuperclass which is generated from the DB and where all the actual
fields are declared.

package nl.reinders.bm;
@Entity
@Table(name="article")
public class Article extends nl.reinders.bm.generated.Article
{
	... almost empty...
}


package nl.reinders.bm.generated;
@MappedSuperclass
public class Article
{
	@OneToMany(mappedBy = "iArticle"...
	...
	@Column(name="description")
	private String iDescription;
	....
}

-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10101376
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.


Jacek Laskowski-4 wrote:
> 
> So I read it that you're relying "on the other mechanisms" TopLink JPA
> provides.
> 

Ah, no, all classes are defined in the persistence.xml. In fact I turned
autodetection explicitely off when I was trying Hibernate (OpenJPA is
attempt 3); my persistent classes are reverse engineered from the DB and
some metatables generate classes that cause trouble, and I explicitely make
them non-persistent by removing them from the <class> list. Sorry.
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10100315
Sent from the open-jpa-dev mailing list archive at Nabble.com.


Re: Open JPA error-Could not locate metadata for the class using alias

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On 4/20/07, tbee <tb...@tbee.org> wrote:
>
> I'm having the same exception. Strange is that the IDENTICAL codebase runs
> without errors under Toplink JPA. I've only changed the provider and
> properties in the persistence.xml and included the OpenJPA jars to the
> project. (That is what JPA should be able to do, afterall.)

If a JPA provider runs in Java SE environments, persistence.xml file
should list all the available persistence classes using <class> to
insure portability.

The spec reads (6.2.1.6 mapping-file, jar-file, class,
exclude-unlisted-classes page 138):

"The class element is used to list a managed persistence class. A list
of all named managed persistence classes must be specified in Java SE
environments to insure portability. Portable Java SE applications
should not rely on the other mechanisms
described here to specify the managed persistence classes of a
persistence unit. Persistence providers may also require that the set
of entity classes and classes that are to be managed must be fully
enumerated in each of the persistence.xml files in Java SE
environments."

So I read it that you're relying "on the other mechanisms" TopLink JPA provides.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Open JPA error-Could not locate metadata for the class using alias

Posted by tbee <tb...@tbee.org>.
I’m having the same exception. Strange is that the IDENTICAL codebase runs
without errors under Toplink JPA. I’ve only changed the provider and
properties in the persistence.xml and included the OpenJPA jars to the
project. (That is what JPA should be able to do, afterall.)
-- 
View this message in context: http://www.nabble.com/Open-JPA-error-Could-not-locate-metadata-for-the-class-using-alias-tf3561516.html#a10095774
Sent from the open-jpa-dev mailing list archive at Nabble.com.