[hibernate-dev] @Entity and inheritance with annotations

2012-03-14 Thread Steve Ebersole
Can someone help me understand whether this is valid annotation mapping:

@Entity
class A {
}

@Entity
class B extends A {
}

?

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 {
}


-- 
st...@hibernate.org
http://hibernate.org
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] @Entity and inheritance with annotations

2012-03-14 Thread Hardy Ferentschik

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
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev