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

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

“detached entity passed to persist error” with JPA/EJB code

The error occurs because the object’s ID is set. Hibernate distinguishes between transient and detached objects and persist works only with transient objects. If persist concludes the object is detached (which it will because the ID is set), it will return the “detached object passed to persist” error. You can find more details here and … 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

tech