Java

SimpleDateFormat + Calendar = thread unsafe

Posted on

http://javarevisited.blogspot.com/2012/03/simpledateformat-in-java-is-not-thread.html 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 […]

Java

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 […]