• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic