Archive

Archive for November 10th, 2009

Tip: Cached Associations in Hibernate Caching

November 10th, 2009 Shrihari No comments

In cases of deep rooted (entity objects with association chaining with other entity objects), there are N+1 select problem, where the chain of associated entity objects are queried and loaded into Hibernate Session from the database, everytime the master entity is loaded. To solve this problem, one should follow these practices:

1) Define the caching strategy on both the associated entity objects along the association chain.
2) Deactivate the lazy-loading on the association link. One has to be selective in choosing association links for deactivating lazy loading.
3) Define the caching strategy on the association link.

Categories: jee-light Tags: ,