Announcement Announcement Module
No announcement yet.
Reference Data: Storage and Access from a browser Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reference Data: Storage and Access from a browser

    In the past I have worked on an application which supplied "RefData" as a service from the JVM heap. The service was intialized in the init method. This was a singelton populated the first time the application ran on the JVM. This was put in place by an Architecture team so I don't know all the details, only that I was able to access this data for rendering in a JSP. The SQL was stored in a properties file.

    I am using Spring, Hibernate, and Tapestry on my current project . Is there a simple way for me to provide our developers with the same kind of thing in this environement?

    I would not want the RefData stored in a session or "Visit" object and I am not sure if "Global" is correct. But I don't want each user to create a new instance when they access a drop down. I just want to take the performance hit of running the queries once, the first time the application is started until the server gets bounced.

  • #2
    Since you are using Hibernate, I would personally just use a second-level cache. What's nice about this is that the data in question is still in the db to be read on first access, and then will be used from memory:



    • #3
      2 solutions available


      There is in fact 2 solutions.

      - First level of cache : getHibernateTemplate().setCacheQueries(true); before your request like this :

      public List getList(){
           return getHibernateTemplate().find("from Country");

      - Second level of cache :
      Create a in the classpath directoy with


      Put in the or in the applicationContext.xml, the 2 properties :

      hibernate.cache.use_query_cache true
      hibernate.cache.provider_class net.sf.hibernate.cache.OSCacheProvider

      Download the lib : oscache-2.*.jar from the site : and put it in your lib dir.

      In this 2 case : just look at your hibernate trace and u can see that the load appears just the first time.



      • #4
        This is exactly what I was looking for, thank you!
        Now I will attempt to implement it...


        • #5
          If you just want to get the second level cache going without downloading oscache, note that Hibernate (and this Spring) ships with ehcache. You can get that going, and then later try oscache, which I believe (but don't know for sure) is more performant...

          Also, the query cache that Fabien mentions may or may not be useful; it has limited applicability, as described here:



          • #6
            I'm trying OSCache and performs well but I have this scenario:

            An intensively accessed form has typical fields "product/subproduct" (really, city - town)

            Cities considered are about 200 and towns per city about 20

            After records retrieval, I have to generate with Velocity some DHTML code to replace town combo box every time city field (another combo) changes

            Yes, I know I can put all in cache (instance memory consumption is really cheap) but I want to avoid -what do you think about- traverse from presentation layer to persistence layer for cached data when another approach could be taken into account:

            What about caching generated DHTML? Is really serious that alternative? I feel that my original problem is in presentation layer, so a "same-layer" solution should be preferable. But I'm affraid I'm being too mystic and far from reality