How to turn on Hibernate caching? How it works?
I have a scenario and like to know if Hibernate caching is in the picture.
A category has a parent category.
class Category {
@ManyToOne(fetch=FetchType.EAGER)
public Category getParent();
}
Category is a tree structure.
Suppose category A has a child category B.
when A is retrieved, all its parents until the root will be retrived because of EAGER: root-->A1-->A2-> ....-->A.
When I ask for category B that is a child of A, its parents until root will be retrieved from user's perspective. Will Hibernate go to the database to read its parent categories from A to the root again? Or can Hibernate cache it so that only B will be retrieved from database and its parents will be from the cache?
The same question for collection with JoinTable. Is there any cache going on? How to configure it ?
Thanks for advice.
Dave
|