SimpleDateFormat + Calendar = thread unsafe

Posted on 1) Use local DateFormat or SimpleDateFormat objects for converting or formatting dates in Java. Making them local ensure that they will not be shared between multiple Threads. 2) If you are sharing Date for SimpleDateFormat class in Java then you need to externally synchronize call to format() and parse() method as they mutate state […]


JPA Cache APIs

Posted on

JPA 2.0 Cache APIs JPA 2.0 provides a set of standard query hints to allow refreshing or bypassing the cache. The query hints are defined on the two enum classes CacheRetrieveMode and CacheStoreMode. Query hints: javax.persistence.cache.retrieveMode¬†: CacheRetrieveMode BYPASS¬†: Ignore the cache, and build the object directly from the database result. USE¬†: Allow the query to […]