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

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

Should I use EJB3 or Spring for my business layer?

There won’t be much difference between EJB3 and Spring based on Performance. We chose Spring for the following reasons (not mentioned in the question): Spring drives the architecture in a direction that more readily supports unit testing. For example, inject a mock DAO object to unit test your business layer, or utilize Spring’s MockHttpRequest object … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)