You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Michael Dick <mi...@gmail.com> on 2006/08/09 20:30:43 UTC

MappedSuperclasses

Can a MappedSuperclass extend an Entity?

I've run into a problem during validation of a MappedSuperclass.  I have an
abstract class (AbstractEmployee) with the @Entity and @Id annotations. The
MappedSuperclass (AbstractFullTimeEmployee) extends it.  Finally a concrete
entity class (FulltimeExemptEmployee) extends the MappedSuperclass.

When the OpenJPA kernel validates the concrete class I get a warning like
this  :
2740  WARN   [main] openjpa.Enhance - An exception was thrown while
attempting to perform class file transformation on
"mdd/entities/FullTimeExemptEmployee":
<4|true|0.9.0> org.apache.openjpa.util.MetaDataException: Type "class
mdd.entities.AbstractFullTimeEmployee" does not declare the same
identity-type as its persistent superclass.
    at org.apache.openjpa.meta.ClassMetaData.validateIdentity(
ClassMetaData.java:1642)
    . . .

The identity type for MappedSuperclasses is set to ClassMetaData.ID_UNKNOWNin
AnnotationPersistenceMetaDataParser.parseClassAnnotations(). Which seems to
ensure that the identity type for a MappedSuperclass will never match the id
type for its superclass (whenever the superclass has an ID).

I don't see anything in the the spec that prevents this scenario, should
this be valid?  I know my example isn't the best, but I hope it at least
helps to illustrate the issue.

Thanks,
-- 
-Michael Dick