Just found that in JPA 2.0 Proposed Final Draft (March 13, 2009): Spec 2.11.2: A mapped superclass, unlike an entity, is not queryable and cannot be passed as an argument to EntityManager or Query operations.
--- On Tue, 4/21/09, Jeremy Bauer <techhu...@gmail.com> wrote: > From: Jeremy Bauer <techhu...@gmail.com> > Subject: Re: Can't query against a MappedSuperclass > To: users@openjpa.apache.org > Date: Tuesday, April 21, 2009, 8:52 AM > Hi Jim, > > It looks like there are inconsistencies in the manual and > provider. I was > able use the em.find() operation with a mapped superclass, > but could not run > a JPQL query which used one. To perform the find > operation, OpenJPA queried > known entity subclasses of the mapped superclass until it > found one that > matched the specified ID. I tried using mapped > superclasses with the base > 1.0 release to make sure this capability hadn't regressed > and 1.0 behaved > the same. So, it doesn't look like this ever worked with > JPQL. > > Have you taken a look at using entity enheritance and the > various entity > inheritance strategies? The TABLE_PER_CLASS strategy > may map fairly well to > a domain model that currently uses mapped superclass over > multiple disparate > entities. It provides query capabilities over the > superclass entity type. > > I've opened JIRA OPENJPA-1043[1] for this issue. > Minimally, the docs should > be updated to reflect that mapped superclasses are only > supported on a find > until such a time they can be supported in a query. > > -Jeremy > > [1] https://issues.apache.org/jira/browse/OPENJPA-1043 > > On Mon, Apr 20, 2009 at 4:33 PM, Fay Wang <fyw...@yahoo.com> > wrote: > > > > > Hi, > > According to openjpa manual: > > > > "Unlike true entities, you cannot query a mapped > superclass" > > > > > > http://openjpa.apache.org/builds/latest/docs/manual/manual.html#jpa_overview_meta_embeddablesuper > > > > > > > > --- On Mon, 4/20/09, jim weaver <jewea...@us.ibm.com> > wrote: > > > > > From: jim weaver <jewea...@us.ibm.com> > > > Subject: Can't query against a MappedSuperclass > > > To: users@openjpa.apache.org > > > Date: Monday, April 20, 2009, 12:38 PM > > > > > > I have the following: > > > > > > @MappedSuperclass class A { } > > > @Entity class B extends A { } > > > @Entity class C extends A { } > > > > > > and I try to do this type of query: SELECT a FROM > A a > > > > > > I receive error message "An error occurred while > parsing > > > the query filter > > > "SELECT a FROM A a". Error > > > message: The name "A" is not a > recognized > > > entity or identifier. Perhaps you meant B, > which is a > > > close match. Known > > > entity names: [B, C]" > > > > > > A is defined in my persistence.xml and my tables > do have > > > the inherited > > > fields from it so I'm pretty sure jpa is > recognizing it. > > > > > > The OpenJPA doc says that the query is > supported.....this > > > is from the 1.2.0 > > > doc: > > > > > > Note > > > OpenJPA allows you to query on mapped > superclasses. A query > > > on a mapped > > > superclass will return all matching subclass > instances. > > > > > > > > > -- > > > View this message in context: > > http://n2.nabble.com/Can%27t-query-against-a-MappedSuperclass-tp2665700p2665700.html > > > Sent from the OpenJPA Users mailing list archive > at > > > Nabble.com. > > > > > > > > > > > > > > >