Spring, Struts and JPA best practice on defining Service classes
Posted on 2009-07-03
I'm relatively new to Spring and JPA, and was wondering the best practice for using Service classes to interact with Struts Actions.
Currently for every POJO entity bean defined in a Model package, I have a corresponding Service interface, and a Service Implementation class in a Service Package with the @Transactional annotation. To be able to use these in any Struts Action, I have to pass these services as arguments to the Action Bean definition in ApplicationContext.xml.
For instance, take a clases Employee, a class Department, and a class Office. All three classes have their entity bean definition, and individual Service and Service implementation classes. And definitions for all three beans in Application Context, and all are passed to the constructor-arg of an EmployeeAction bean.
Is this the recommended approach or is there a simpler way to do this? It seems that going through all these to only use a Department for a pull down list in a JSP, and assign the Department object to the Employee, and persist it, is a bit overkill.
Any hints aprreciated.