• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring annotation with inheritance

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm trying build a project with spring and I have some generic classes and I'd like know if when I have inheritance, the annotation will go to be inherited too ? For example:

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes they do. Some people put their annotation on their interfaces.

Based on the code you wrote I have two comments about the abstract class.

1) You are using JPA and injecting the EntityManager, there is absolutely no reason why you need to extend HibernateDaoSupport. You are not gaining anything by it and now you are tightly coupling your code with a Spring specific class.
2) You are putting a bean name in your @Repository annotation, but plan to extend it by many Repository classes, which each will need their own distinct name. Spring will automatically give it a name, and since you are going the route of annotations, then it is assumed you are auto wiring, which spring does by type, so a name besides what Spring automatically generates is enough.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic