• 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

How to autowire type Class into constructor and instantiate bean which is superclass by super()?

 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I have Spring bean that should be instantiated via constructor injection:

Here I don't know how to autowire bean of type java.lang.Class<IntermediateUser> with parameter IntermediateUser.
Super class is instantiated by super(userClass) and it is also spring bean:


I need two spring beans - the first is IntermediateUserDao that has inherited methods from super class(JuniorUserDao) which is also spring bean. For inherited methods to work properly I pass Class<T> userClass by super(userClass).

Will I have two spring beans one is IntermediateUserDao that has inherited methods from super class and separately JuniorUserDao that has its own Class object injected via constructor.

Thank you!
 
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

What about



Best regards,
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I did not try this. But my IntermediateUser class is not spring bean and it is entity.
Instead I created new spring bean

And now constructor autowires needed property of this bean :
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic