I\'m trying to get used to how JSF works with regards to accessing data (coming from a spring background)
I\'m creating a simple example that maintains a list of use
It is a DAO
, well actually a repository but don't worry about that difference too much, as it is accessing the database using the persistence context.
You should create a Service
class, that wraps that method and is where the transactions are invoked.
Sometimes the service
classes feel unnecessary, but when you have a service
method that calls many DAO
methods, their use is more warranted.
I normally end up just creating the service
, even if it does feel unnecessary, to ensure the patterns stay the same and the DAO
is never injected directly.
This adds an extra layer of abstraction making future refactoring more flexible.