EJB 3.0 – Nested Transaction != Requires New?

RequiresNew does not create a nested transaction because the first transaction is suspended while the second transaction is running. A nested transaction looks like this: Nested transaction example > method1 – begin tran1 > method2 – begin tran2 workA < method2 – commit tran2 < method1 – rollback tran1 (tran2 also rolled back because it’s … Read more

Difference between a “jta-datasource” and a ” resource-local ” datasource?

The terms “jta-datasource” and “resouce-local datasource” are a little vague to me. I guess you actually refer to the jta-datasource and non-jta-datasource elements. In short: if the transaction type of the persistence unit is JTA, the jta-datasource element is used to declare the JNDI name of the JTA data source that will be used to … 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

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

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