I am developing a database driven web-application in Java EE and I am wondering about the benefits of using EJbs.
If I understand correctly it is best practice to use EJBs for every kind of business logic or database transaction.
I am using Hibernate as my JPA and here is my question:
What are the benefits of using an injected EJB as DAO instead of a regular Java class as DAO which gets called from my Managed Bean? And what is the difference?
I am new to Java EE, so this might be a beginner’s question.
If you use EJBs, you can use a number of very important services provided by the EJB container. The most important ones that are useful to pretty much anyone are dependency injection and declarative transactions. Both of these can alternatively be provided by the Spring framework. For very large applications, it can be useful that EJBs have a well-defined model for clustering, but you’ll probably not need that.