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

46 messages Options
Embed this post
Permalink
1 2 3
tbee

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by Marina Vatkina

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).

Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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:[hidden email]]
> Sent: Friday, April 20, 2007 10:20 AM
> To: [hidden email]
> 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.
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by Craig L Russell
+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: [hidden email] [mailto:[hidden email]]
> Sent: Tuesday, April 24, 2007 9:40 AM
> To: [hidden email]
> 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:[hidden email] 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.
tbee

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by Patrick Linskey

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
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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:[hidden email]]
> Sent: Tuesday, April 24, 2007 10:20 AM
> To: [hidden email]
> 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.
Marina Vatkina

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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).
>
>
tbee

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

Reply Threaded More More options
Print post
Permalink

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?
tbee

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by Patrick Linskey

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

openjpa-project-0.9.6-incubating-binary
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
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:[hidden email]]
> Sent: Tuesday, April 24, 2007 11:04 PM
> To: [hidden email]
> 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.
tbee

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

Reply Threaded More More options
Print post
Permalink

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?
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
> 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:[hidden email]]
> Sent: Tuesday, April 24, 2007 11:24 PM
> To: [hidden email]
> 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.
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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:[hidden email]]
> Sent: Tuesday, April 24, 2007 11:24 PM
> To: [hidden email]
> 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.
tbee

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by Patrick Linskey

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.
Marina Vatkina

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

Reply Threaded More More options
Print post
Permalink
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.
>

tbee

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

Reply Threaded More More options
Print post
Permalink

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?
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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:[hidden email]]
> Sent: Wednesday, April 25, 2007 12:03 AM
> To: [hidden email]
> 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.
tbee

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

Reply Threaded More More options
Print post
Permalink

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?
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
> 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:[hidden email]]
> Sent: Wednesday, April 25, 2007 1:06 AM
> To: [hidden email]
> 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.
Patrick Linskey

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

Reply Threaded More More options
Print post
Permalink
In reply to this post by tbee
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:[hidden email]]
> Sent: Wednesday, April 25, 2007 1:06 AM
> To: [hidden email]
> 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.
tbee

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

Reply Threaded More More options
Print post
Permalink

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!
1 2 3