persistence@glassfish.java.net

RE: abstract entity superclasses

From: jeff <jeffrey.blattman_at_yahoo.com>
Date: Fri, 9 Mar 2007 13:12:44 -0800 (PST)

see exception below. i tried following the example from 35 in the spec. i have the @InheritanceStrategy annotation in the abstract class, and the @DiscriminatorValue annotation in all subclasses.

it's a little unclear to me which of the annotations are required, and which i can leave off an have it pick some reasonable defaults. the spec is a little lean in this section.

thanks!

javax.persistence.EntityExistsException:
Exception Description: This class does not define a public default constructor, or the constructor raised an exception.
Internal Exception: java.lang.InstantiationException
Descriptor: RelationalDescriptor(com.sun.portal.pom.PortletEntity --> [DatabaseTable(PORTLETENTITY)])

Gordon Yorke <gordon.yorke_at_oracle.com> wrote: You should be able to mark the abstract Foo class as being an Entity. Can you provide the exception that you are getting?
 --Gordon
    -----Original Message-----
From: jeff [mailto:farble1670_at_yahoo.com]
Sent: Friday, March 09, 2007 3:55 PM
To: persistence_at_glassfish.dev.java.net
Subject: abstract entity superclasses


i have class Bar extends Foo. i want Foo to contain persistent fields inherited by Bar, but i also want Foo to be abstract.

is this possible? if i leave the @Entity annotation, then i get an error telling me that the class cannot be instantiated (right, it's abstract). this sort of puzzles me though because i never try to create any instances of it.

if i remove the entity annotation, i get an error at runtime from Bar saying it can't find the ID ... the ID field is defined in the abstract base class Foo.

any ideas?
thanks.
      

---------------------------------
   Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

 
---------------------------------
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.