In a spring hibernate java project with(controller – services – dao – entity layers), i am having abstract factory pattern (the abstract class has 2 abstract methods). In the implemented classes of abstract factory pattern i am having dao methods(to run the named queries). Now when the request comes to the service impl the dao from another Service class it gives null pointer excecption
I have autowired the dao classes in the services impl
`
AbstractFruitService - [addToBasket() and removeFromBasket()]
|
|- SeasonalFruitsServicsImpl - SeasonalFruitsDAO
|
|- BerryFruitsServiceImpl - BerryFruitsDAO
i cant add @Service(“abstractFruitService”) to both SeasonalFruitsServicsImpl and BerryFruitsServiceImpl it gives error – conflicts with existing, non-compatible bean definition of same name and class
Not sure if the spring static/instance factory method is useful in this case, i tries this also but didnt work
Is there any approach
Using the annotation
@Transactional(propagation = Propagation.REQUIRES_NEW)works perfect for my code, on the service method i add this functionality and it worked fine