Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1540
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: MappedSuperClass annotation |
| Date | 2012-01-27 19:24 -0800 |
| Organization | albasani.net |
| Message-ID | <jfvpov$g19$1@news.albasani.net> (permalink) |
| References | <4f22cb6e$2@news.x-privat.org> <jfurls$srq$1@news.albasani.net> <L6EUq.3960$Au5.2987@newsfe23.iad> |
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.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
MappedSuperClass annotation Pidi <lamia@mail.com> - 2012-01-27 17:05 +0100
Re: MappedSuperClass annotation Lew <noone@lewscanon.com> - 2012-01-27 10:50 -0800
Re: MappedSuperClass annotation Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-01-27 12:50 -0800
Re: MappedSuperClass annotation Lew <noone@lewscanon.com> - 2012-01-27 19:24 -0800
Re: MappedSuperClass annotation Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-01-29 08:53 -0800
Re: MappedSuperClass annotation Lew <noone@lewscanon.com> - 2012-01-29 10:05 -0800
Re: MappedSuperClass annotation Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-01-29 22:45 -0800
Re: MappedSuperClass annotation Lew <noone@lewscanon.com> - 2012-01-30 10:06 -0800
Re: MappedSuperClass annotation Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-31 06:52 -0400
Re: MappedSuperClass annotation Lew <noone@lewscanon.com> - 2012-01-31 11:07 -0800
Re: MappedSuperClass annotation Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-28 12:02 -0400
csiph-web