It looks like it's working from a "put" perspective, but is it working from a "read" perspective? I'm not that familiar with Hibernate caching so you might have better luck reading their documentation or asking this question on their forums.
Matt On Fri, Oct 9, 2009 at 5:51 AM, Nelson Biasura <nelson.bias...@aurisoftsys.com> wrote: > After hours of research and testing.. I finally made the logging work.. I > added @Cache annotation in my Object > then the logs came out in my tomcat. Putting @Cache annotation in object > that i wanted to be cache and configuring ehcache.xml and > adding the below code in log4j.xml is what i did so far. > > log4j.xml > ------------------------- > <logger name="org.hibernate.cache"> > <level value="DEBUG"/> > </logger> > ------------------------- > > > > Below is the log: > > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1830819 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1839827 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1842521 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1848512 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1852080 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1866928 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1873554 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1874178 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1877083 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1878320 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1883315 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1887246 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1889448 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1899559 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1903456 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1911216 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1917414 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1919508 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1933371 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1933393 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1938679 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1943884 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1951918 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1952598 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1953010 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1954255 > [http-80-1] ReadOnlyCache.put(58) | Caching: > com.company.project.model.GroupProduct#1873555 > > > Can i say that my second-level caching is working with this logs? My loading > speed is still the same. > > here is my latest log on milliseconds.. > > before > 3251 ms > 3230 ms > 3339 ms > > > after > 3462 ms > 3260 ms > 3226 ms > > based on the example on http://www.devx.com/dbzone/Article/29685/0/page/2 > i am assuming that the load will cut 70-80% in loading once the object is > stored in > cache.. > > > > > Matt Raible wrote: >> >> I would turn up logging on Hibernate and EhCache to see if the cache >> is being used. You should be able to do this in your log4j file. >> >> Matt >> >> On Thu, Oct 8, 2009 at 2:01 AM, Nelson Biasura >> <nelson.bias...@aurisoftsys.com> wrote: >> >>> >>> After configuring ehcache.xml adding my object (GroupProduct) >>> >>> Code: ehcache.xml >>> ---------------------------------- >>> <ehcache> >>> >>> <diskStore path="c:\\temp"/> >>> >>> <defaultCache >>> maxElementsInMemory="10000" >>> eternal="false" >>> overflowToDisk="true" >>> timeToIdleSeconds="120" >>> timeToLiveSeconds="120" >>> diskPersistent="false" >>> diskExpiryThreadIntervalSeconds="120"/> >>> <!-- my new object to include in cache --> >>> <cache name="com.company.project.model.GroupProduct" >>> maxElementsInMemory="100000" >>> eternal="true" >>> overflowToDisk="false" >>> /> >>> </ehcache> >>> ---------------------------------- >>> >>> >>> >>> Log the measure the milliseconds load in DaoHibernate: >>> >>> Code: GroupProductDaoHibernate >>> ----------------------------------- >>> public List<GroupProduct> findByServiceId(String serviceId) { >>> Long serviceIdLong = Long.valueOf(serviceId); >>> List<GroupProduct> gpDTOList = new ArrayList<GroupProduct>(); >>> >>> long a = System.currentTimeMillis(); >>> log.debug("start time - DAO: " + a); >>> >>> gpDTOList = getHibernateTemplate().find("from GroupProduct gp where >>> gp.version=0 and gp.serviceID=" + serviceIdLong); >>> >>> long b = System.currentTimeMillis(); >>> log.debug("Execution time - DAO: " + (b - a) + " ms"); >>> return gpDTOList; >>> } >>> --------------------------------------- >>> >>> I got almost the same result in loading >>> >>> Before: >>> 9453 ms >>> 8688 ms >>> 9434 ms >>> >>> After: >>> 8492 ms >>> 9000 ms >>> 8239 ms >>> >>> >>> I am missing something here? is there something i need to tweak or >>> configure/add etc.. To >>> get going on second level cache.. >>> >>> Thanks >>> >>> >>> >>> >>> >>> >>> >>> Matt Raible wrote: >>> >>>> >>>> I believe adding the object into ehcache.xml is enough, but you might >>>> want to check EhCache/Hibernate documentation to be sure. >>>> >>>> Matt >>>> >>>> On Wed, Oct 7, 2009 at 10:15 AM, Nelson Biasura >>>> <nelson.bias...@aurisoftsys.com> wrote: >>>> >>>> >>>>> >>>>> Thanks for the clarification Matt. Another thing do i still need to add >>>>> @Cache annotation in the object that >>>>> i want to be cache or adding the object into ehcache.xml is enough that >>>>> i >>>>> dont need to configure anything anymore >>>>> and ready for second level caching? >>>>> >>>>> Thanks for letting me understand. >>>>> >>>>> >>>>> Matt Raible wrote: >>>>> >>>>> >>>>>> >>>>>> No, you should not need to do anything additional - EhCache is enabled >>>>>> by default. You might want to modify ehcache.xml to configure which >>>>>> objects to cache though. >>>>>> >>>>>> Matt >>>>>> >>>>>> On Wed, Oct 7, 2009 at 7:28 AM, Nelson Biasura >>>>>> <nelson.bias...@aurisoftsys.com> wrote: >>>>>> >>>>>> >>>>>> >>>>>>> >>>>>>> Hello, >>>>>>> >>>>>>> Im using Appfuse 2.0.2 and I trying to configure second level cache, >>>>>>> I >>>>>>> found >>>>>>> article written by matt >>>>>>> that leads me to this link >>>>>>> http://www.devx.com/dbzone/Article/29685/0/page/2 .. In this >>>>>>> example >>>>>>> it >>>>>>> activated >>>>>>> the second level caching through hibernate.cfg.xml adding this code >>>>>>> >>>>>>> |<property name="hibernate.cache.provider_class"> >>>>>>> org.hibernate.cache.EHCacheProvider >>>>>>> </property> >>>>>>> >>>>>>> My question is do i still need to do this? i found in >>>>>>> applicationContext-dao.xml >>>>>>> >>>>>>> <property name="hibernateProperties"> >>>>>>> <value> >>>>>>> hibernate.dialect=${hibernate.dialect} >>>>>>> hibernate.query.substitutions=true 'Y', false 'N' >>>>>>> hibernate.cache.use_second_level_cache=true >>>>>>> >>>>>>> hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider >>>>>>> </value> >>>>>>> <!-- Turn batching off for better error messages under >>>>>>> PostgreSQL >>>>>>> --> >>>>>>> <!-- hibernate.jdbc.batch_size=0 --> >>>>>>> </property> >>>>>>> >>>>>>> I assumed that this activate my second-level of caching. Anyone could >>>>>>> help >>>>>>> clarify it? >>>>>>> >>>>>>> Thanks in advance. :) >>>>>>> | >>>>>>> >>>>>>> >>>>>>> >>>>>>> --------------------------------------------------------------------- >>>>>>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>>>>>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>>>>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>>>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>>>> >>>>> >>>>> >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>>> >>>> >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>> >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >> For additional commands, e-mail: users-h...@appfuse.dev.java.net >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net