posted 7 years ago
Incidentally, the quick answer to that question is that there's a JSF-Spring bridge that you can configure into the faces-config. It allows Spring beans to be referenced in EL exactly like JSF beans are and can be used to inject persistence interface services into Managed Beans. As well as other Spring services, such as email, scheduling, and so forth.
My typical large JSF/Spring/Hibernate-JPA app has a persistence service layer that deals with sets of related data and is transactional. This allows me to keep all the persistence Model objects detached while working in JSF code and in the View Rendering phase (which I personally recommend). The persistence service layer basically deals with data as business functions.
Below the persistence layer, I have a DAO layer. The JSF code never talks to anything in here directly, only via the persistence service layer (in extreme cases, that will make a persistence service class a mere proxy for the DAO, but such is life). The DAOs are Spring-injected into the persistence services that need them. The DAOs are the CRUD/Finder code for individual tables (or sometimes parent/child table sets), whereas the persistence services handle heterogeneous groups of tables (a "working set"). Like the persistence services, the DAOs are transactional, and they will inherit transaction context, so if a persistence transaction invokes DAO functions, all the DAO functions will commit or rollback when the persistence service does.
That's all it takes.
Often the most important part of the news is what they didn't tell.