[hibernate-dev] @Entity and inheritance with annotations
Hardy Ferentschik
hardy at hibernate.org
Wed Mar 14 16:26:27 EDT 2012
On Mar 14, 2012, at 9:17 PM, Steve Ebersole wrote:
> Can someone help me understand whether this is valid annotation mapping:
>
> @Entity
> class A {
> }
>
> @Entity
> class B extends A {
> }
That's valid. The @Inheritance annotation is optional. If not specified InheritanceType.SINGLE_TABLE is used.
> My understanding was that an @Entity extending an @Entity had to specify
> an inheritance strategy? And that this example is really the point of
> @MappedSuperclass:
>
> @MappedSuperclass
> class A {
> }
>
> @Entity
> class B extends A {
> }
Citing from the spec here:
An entity may inherit from a superclass that provides persistent entity state and mapping information,
but which is not itself an entity. Typically, the purpose of such a mapped superclass is to define state
and mapping information that is common to multiple entity classes.
--Hardy
More information about the hibernate-dev
mailing list