For starters I think it is a bad idea to make your controller transactional, the controller should be a thin integration layer which calls the service layer, which should be transactional not your controller.
You don't need setters simply put @Autowired on the field and spring will do the injection for you. To have injection working you need either context:component-scan in your configuration (if you scan for @Controllers) if you manually define the controllers you need a context:annotation-config to enable injection.
Controller
Code:
@Controller
@RequestMapping("/promote")
public class PromotionController {
@Autowired
protected Gson gson;
@Autowired
private PromotionService promotionService;
@RequestMapping(method = {RequestMethod.POST, RequestMethod.PUT})
public final HttpEntity<String> promote(@RequestBody final String promotionJson) {
Promotion promotion = gson.fromJson(promotionJson, Promotion.class);
Project result = promotionService.someMeaningfulBusinessName(promotion);
return JsonEntity.create(gson.toJson(result));
}
}
Service
Code:
@Service
@Transactional
public class DefaultPromotionService implements PromotionService {
@Autowired
protected ProjectDao projectDao;
@Autowired
protected ProspectDao prospectDao;
@Override
public Project someMeaningfulBusinessName(Promotion promotion) {
Prospect target = promotion.getTarget();
Project result = promotion.getResult();
result.setCommentStack(target.getCommentStack());
projectDao.addEntity(result);
prospectDao.removeEntity(target.getId());
}
}
This way you also don't need cglib as you are simply using interfaces (assuming your daos are also using interfaces).