When to Use EntityManager.clear()?

The articles explains it. Clearing the entity manager empties its associated cache, forcing new database queries to be executed later in the transaction. It’s almost never necessary to clear the entity manager when using a transaction-bound entity manager. I see two reasons to clear: when doing batch processing, in order to avoid having a giant … Read more

Spring Boot + JPA2 + Hibernate – enable second level cache

To sum everything (L2 cache and query cache) up: The first thing to do is to add cache provider (I recommend using EhCache) to your classpath. Hibernate < 5.3 Add the hibernate-ehcache dependency. This library contains EhCache 2 which is now discontinued. <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>your_hibernate_version</version> </dependency> Hibernate >=5.3 In newer versions of Hibernate caches … Read more

Grails 2.4 and hibernate4 errors with run-app

It’s a bug, it seems that you can leave it that way and will cause no problem, but if you don’t want to see the message here are some solutions: (Edit: Option 2 seems to work better (see comments in this post)) 1.- singleSession configuration from DataSource.groovy https://jira.grails.org/browse/GRAILS-11198 2.- overriding the H2 dialect: public class … Read more