openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Inheritance: Subclasses are not recognised
Date Fri, 15 May 2009 14:25:54 GMT
Hi Jasmin,

Do you have all your entities listed in persistence.xml?

-mike

On Fri, May 15, 2009 at 7:08 AM, Jasmin Riemer <Jasmin.Riemer@gmx.de> wrote:

> Hello everybody,
>
> currently, I am working with OpenJPA in the Spring framework and try to
> implement the following:
>
> I inherit certain subclasses from a mainclass. All these classes should be
> mapped to a single table, so I use InheritanceType.SINGLE_TABLE and add a
> discriminator value to each subclass.
>
> Simplified, it looks like this:
>
> @Entity
> @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name="doc_type",
> discriminatorType=DiscriminatorType.STRING)
> public abstract class Document {
>
> // ...
>
> }
>
> @Entity
> @DiscriminatorValue(value="Magazine")
> public class Magazine extends Document {
>
> // ...
>
> }
>
> @Entity
> @DiscriminatorValue(value="Book")
> public class Book extends Document {
>
> // ...
>
> }
>
> Unfortunately, I get the following error message when I try to load data
> from the database:
>
> Exception in thread "main"
> org.springframework.dao.InvalidDataAccessApiUsageE xception: Could not map
> discriminator value "Book" to any known subclasses of the requested class
> "project.entities.Document" (known discriminator values: [Document,
> Magazine]).; nested exception is <openjpa-1.2.1-r752877:753278 nonfatal user
> error> org.apache.openjpa.persistence.ArgumentException: Could not map
> discriminator value "Book" to any known subclasses of the requested class
> "project.entities.Document" (known discriminator values: [Document,
> Magazine]).
>
> It seems that there are only known the main class and the subclass
> "Magazine", but there is a problem with "Book" (and some other classes
> inherited from "Document").
>
> I do not have much experience with OpenJPA and Spring and thus I have no
> clue how to solve this problem. Anybody out there who has an idea or maybe
> had a similar problem?
> Is there maybe something special I could have used accidentally for
> "Magazine", but not for the other classes?
> --
> Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate +
> Telefonanschluss für nur 17,95 Euro/mtl.!*
> http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message