What is the difference between DAO and Repository patterns?

DAO is an abstraction of data persistence. Repository is an abstraction of a collection of objects. DAO would be considered closer to the database, often table-centric. Repository would be considered closer to the Domain, dealing only in Aggregate Roots. Repository could be implemented using DAO‘s, but you wouldn’t do the opposite. Also, a Repository is … Read more

How can I avoid the Warning “firstResult/maxResults specified with collection fetch; applying in memory!” when using Hibernate?

Although you are getting valid results, the SQL query fetches all data and it’s not as efficient as it should. So, you have two options. Fixing the issue with two SQL queries that can fetch entities in read-write mode The easiest way to fix this issue is to execute two queries: . The first query … Read more

JSF request scoped bean keeps recreating new Stateful session beans on every request?

Stateful session beans (SFSB) are not exactly what you think they are. You seem to think that they behave somehow like session scoped JSF managed beans. This is untrue. The term “session” in EJBs has an entirely different meaning than the HTTP session which you’ve had in mind. The “session” in EJBs must be interpreted … Read more