openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dyer" <danielwd...@dsl.pipex.com>
Subject Re: Question about MappedSuperclass
Date Thu, 13 Dec 2007 22:21:19 GMT
On Thu, 13 Dec 2007 21:45:32 -0000, Alexander Saint Croix  
<saintx.opensource@gmail.com> wrote:

> My question is this: Must my abstract superclass possess a primary key
> field?  I do not intend for Archetype itself ever to be instantiated.  I
> _believe_ I should annotate it with MappedSuperclass.  Is this correct,
> and/or will this work in OpenJPA?

I don't see why not.  This sounds similar to the approach I am using.  It  
works fine for me.

> Not all of my subclasses have their own primary key fields.  Some use
> embedded IDs and some use foreign keys, depending on circumstances.  So  
> it
> seems unlikely that creating the ID field in the superclass is the  
> correct
> way to go about matters.
>
> I read section 2.1.9.2 in the persistence spec, and all of the examples  
> have
> primary keys defined, both for the MappedSuperclass and for the abstract
> entity classes, though nothing regarding the necessity of primary keys in
> Mapped Superclasses is ever explicitly stated (so far as I can see).

I have abstract mapped super-classes without keys and concrete sub-classes  
with keys.  I haven't noticed any problems.

Dan.

-- 
Daniel Dyer
http://www.uncommons.org

Mime
View raw message