Caching in Spring Hibernate application

March 09, 2012 By: admin Category: Hibernate, Spring

  • Object or entity caching
  • Method’s return value caching

Object or entity caching

  • Write a custom cache provider class
  • package com.technaugh.cache;
    import java.util.Properties;
    import org.hibernate.cache.Cache;
    import org.hibernate.cache.CacheException;
    import org.hibernate.cache.CacheProvider;
    import net.sf.ehcache.CacheManager;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.hibernate.cache.Timestamper;
     *   Class      : CustomCacheProvider
     *   Created on : Jan 12, 2011 4:27:24 PM
     *   Author     : arahman
    public class CustomCacheProvider implements CacheProvider {
        private static Log logger = LogFactory.getLog(CacheProvider.class);
        private CacheManager cacheManager;
        public CustomCacheProvider(CacheManager cacheManager) {
            this.cacheManager = cacheManager;
        public Cache buildCache(String name, Properties props) throws CacheException {
            try {
                net.sf.ehcache.Ehcache cache = cacheManager.getEhcache(name);
                if (cache == null) {
                    cache = cacheManager.getEhcache(name);
                logger.debug("Cache details: "+cache.toString());
                return new net.sf.ehcache.hibernate.EhCache(cache);
            } catch (net.sf.ehcache.CacheException e) {
                throw new CacheException(e);
        public long nextTimestamp() {
        public void start(Properties arg0) throws CacheException {
            //throw new UnsupportedOperationException("Not supported yet.");
        public void stop() {
            //throw new UnsupportedOperationException("Not supported yet.");
        public boolean isMinimalPutsEnabledByDefault() {
            return false;
  • Define Spring bean ‘sessionFactory’
  • Create ehcache-wwl.xml
  • Configure object mapping ( in *hbm.xml file) files for caching

How to solve -> Warning: Cannot modify header information – headers already sent by …

May 07, 2010 By: admin Category: Bugs, PHP

A common problem PHP developers may encounter while redirect a page to another is :

Warning: Cannot modify header information – headers already sent by ….

when using the code below:

header( "Location: $url" );

There are different ways to solve this problem: Read more →

Taste the first cup of your Android mobile application – Part 2 : Develop and run your Android application

May 06, 2010 By: admin Category: Android, Mobile

In the previous part of this article, we showed you how to setup Android development environment. Now your are ready to develop your own application in this environment. If have not yet setup your environment, please see the previous part of this article. Read more →

Taste the first cup of your Android mobile application – Part 1 : Setup Android development environment

April 30, 2010 By: admin Category: Android, Mobile

Android is an open source mobile operating system developed by Google. Actually, it’s not just an operating system, it is a software stack for mobile devices that includes an operating system, middleware and key applications. Read more →

How do I find the number of columns of a HTML table by using jQuery?

April 29, 2010 By: admin Category: jQuery

Some times, in Javascript, we need to find the number of columns in a HTML table which is built dynamically with the data retrieved from database. jQuery provides built-in functionality for that. Read more →

How to build, deploy and run uPortal-3.2.1 with Tomcat application server and MySQL database on Windows

April 25, 2010 By: admin Category: Portals, uPortal

uPortal is an open source Java-based portal framework with built-in portlets and allows developers to develop custom portlets on top of it. uPortal can aggregate content, present self-service applications, personalize presentation and content on the basis of groups and user attributes. The important features of uPortal are listed below as described by uPortal’s website. Read more →

Call to undefined function mb_strpos() or mb_stripos or mb_strlen or mb_strtoupper or mb_stristr

April 12, 2010 By: admin Category: dotProject

mbstring (Multibyte String) provides multibyte specific string functions that help you deal with multibyte encodings in PHP. In addition to that, mbstring handles character encoding conversion between the possible encoding pairs. mbstring is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience. Read more →

How to upgrade dotProject

April 12, 2010 By: admin Category: dotProject

dotProject is a very useful open source project management software, written using PHP and MySQL. It includes modules for companies, projects, tasks (with Gantt charts), forums, files, calendar, contacts, tickets/helpdesk, multi-language support, user/module permissions and themes. Read more →

How to retrieve all the radio button groups’ values in a hash table?

April 12, 2010 By: admin Category: JavaScript, jQuery

Some times we need to design a HTML form with dynamic radio button groups that means :

  • data is retrieved from a database
  • we don’t know how many radio button groups would be
  • we don’t know what each group’s name would be

We just want to retrieve values of all radio button groups and send them to the server as a name value pair. Read more →

Object orientation in PHP

December 24, 2009 By: admin Category: OOP, PHP

Programmers with Java or other objected-oriented programming background who want to learn PHP, this article may be helpful for them. PHP is not a typed programming language and hence it is not highly objected-oriented. It does allow coding like plain text as a procedural language or some sort in objected-oriented fashion like Java, C++, C#. We will see which object-oriented features does it support and which not. If you want to continue your objected-oriented programming habit anyway in PHP, go ahead. Read more →