Re: Can't query against a MappedSuperclass

2009-04-21 Thread Jeremy Bauer
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.
 
 






Re: Can't query against a MappedSuperclass

2009-04-21 Thread Fay Wang

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.
  
  
 
 
 
 
 





Re: Can't query against a MappedSuperclass

2009-04-21 Thread Jeremy Bauer
Hi Fay,

The JPA 1.0 and 2.0 draft spec clearly state that this isn't a requirement
of JPA, but a note in the OpenJPA documentation (section 1.3) seems to
indicate that OpenJPA does support it as an OpenJPA extension.

openjpa doc

Unlike true entities, you cannot query a mapped superclass, pass a mapped
superclass instance to any EntityManager or Query methods, or declare a
persistent relation with a mapped superclass target.

...then
Note

OpenJPA allows you to query on mapped superclasses. A query on a mapped
superclass will return all matching subclass instances. OpenJPA also allows
you to declare relations to mapped superclass types; however, you cannot
query across these relations.
/openjpa doc

Using a mapped superclass with the em.find() operation over very simple
entity subclasses seemed to work fine, but JPQL queries do not.

-Jeremy

On Tue, Apr 21, 2009 at 11:32 AM, Fay Wang fyw...@yahoo.com wrote:


 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.
   
   
  
  
  
  
 






Re: Can't query against a MappedSuperclass

2009-04-21 Thread Fay Wang

Ya, this apparently is an inconsistency...

--- 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, 9:53 AM
 Hi Fay,
 
 The JPA 1.0 and 2.0 draft spec clearly state that this
 isn't a requirement
 of JPA, but a note in the OpenJPA documentation (section
 1.3) seems to
 indicate that OpenJPA does support it as an OpenJPA
 extension.
 
 openjpa doc
 
 Unlike true entities, you cannot query a mapped superclass,
 pass a mapped
 superclass instance to any EntityManager or Query methods,
 or declare a
 persistent relation with a mapped superclass target.
 
 ...then
 Note
 
 OpenJPA allows you to query on mapped superclasses. A query
 on a mapped
 superclass will return all matching subclass instances.
 OpenJPA also allows
 you to declare relations to mapped superclass types;
 however, you cannot
 query across these relations.
 /openjpa doc
 
 Using a mapped superclass with the em.find() operation over
 very simple
 entity subclasses seemed to work fine, but JPQL queries do
 not.
 
 -Jeremy
 
 On Tue, Apr 21, 2009 at 11:32 AM, Fay Wang fyw...@yahoo.com
 wrote:
 
 
  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.


   
   
   
   
  
 
 
 
 
 





Re: Can't query against a MappedSuperclass

2009-04-20 Thread Marc Logemann
In the same documentation the following is stated and this was always  
my definition of querying mappedSC.


Section 1.3

A mapped superclass is a non-entity class that can define persistent  
state and mapping information for entity subclasses. Mapped  
superclasses are usually abstract. Unlike true entities, you cannot  
query a mapped superclass, pass a mapped superclass instance to any  
EntityManager or Query methods, or declare a persistent relation with  
a mapped superclass target. You denote a mapped superclass with the  
MappedSuperclass marker annotation. 


So whats correct here? The Note says the opposite...  Perhaps it  
should be made clearer but i always thought that the note is not true,  
because in my code, i experienced the same as Jim.


So any feedback from the core team appreciated

---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de




Am 20.04.2009 um 21:38 schrieb jim weaver:



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.