I am using Spring 3.1 and have my DAO and service layer(transactional) written.
However in a special case to avoid a lazy init exception I have to make a spring mvc
You'll need to implement an interface so that Spring has something it can use as a Proxy interface:
@Controller
public interface AuthenticationController {
ModelAndView home(HttpServletRequest request, HttpServletResponse response);
}
@Controller
public class AuthenticationControllerImpl implements AuthenticationController {
@RequestMapping(value="/home.html",method=RequestMethod.GET)
@Transactional
@Override
ModelAndView home(HttpServletRequest request, HttpServletResponse response){
.....
}
}
Spring will implement the transactional logic using JDK dynamic proxies, these rely on proxied classes implementing suitable interfaces. It's also possible to use CGLib proxies which don't require interfaces.
There is a nice article about this link