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
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.
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?
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.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.