Daniel Pitts wrote:
Lew wrote:
Pidi wrote:
If an abstract class inherits from an abstract superclass annotated
with
@MappedSuperclass, it inherits the annotation too or if I want both
annotated
I have to replicate the annotation?
Ex:
@MappedSuperclass
public abstract Class1 {
...
}
@MappedSuperclass <-- I have to declare it or it's implicit?
public abstract Class2 extends Class1{
...
}
You have to declare it. Annotations do not inherit.
True, and that annotation specifically needs to be declared everywhere
you
want the effect.
In general though, it is up to the framework which utilizes the
annotations to
decide if they want to climb up the inheritance or not.
Good point, but I couldn't come up with an example that does, and
certainly none for JPA.
This is at least hinted if not evident from the documentation, for example:
<http://docs.oracle.com/javaee/6/tutorial/doc/bnbqn.html>
in which the very introduction of entities shows the need to repeat the
'@Entity' annotations at each level of inheritance.
That said, the need for multiple levels of inherited '@MappedSuperclass'
annotated types should be vanishingly rare. There's a very, very good
chance that the OP should *STOP* what they're doing and reconsider, then
get rid of the idea. I cannot even think of a scenario where it would
help. It goes firmly against the intended purpose of that annotation.
combinations on some entities. Not often, but it does happen in real