Cache or not cache?

  • PrettyHandling

    PrettyHandling - 2004-08-20


    I just wanna ask if it is ok to load list of countries from Hibernate or just hard code in JSP page?

    This is because my 1st page  is to ask user to select their country. Hence, should I get a list of country from Hibernate or jsut hard code inside the JSP page? If I get from Hibernate everytime, will it waste a lot of resources?

    My Hibernate is link with Spring with applicationContext.xml


    • Matt Raible

      Matt Raible - 2004-08-20

      Since the list of countries really never changes, you could probably do either - or load them at application startup and stuff them in the servlet context.

      • PrettyHandling

        PrettyHandling - 2004-08-21

        Hi guys,

           So I should just do a 1st level caching like when the application startup, I will just get from Hibernate and put it into a Map. I am just afraid that as list of countries will only change like maybe....once a year and incur some performance issues and wasting resources as once user enter the website, the application will always query from Hibernate. So perhaps I should just hardcode inside JSP page?


    • Alex Shn

      Alex Shn - 2004-08-20

      Caching can be done in hibernate.

      What you are looking for is query caching. It practically does not incur any performance issues. If however you cache just a class and iterate thru the result of the query you will pay a bit in perfomance every time you list the countries.

      My advice buy Hibernate in Action book and read chapter 5. It will clarify a lot of things about caching in hibernate and in the long run will save you a lot of time not developong stuff that comes free with Hibernate :-)



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks