mn7 wrote:
Hey
I have quite a number of "Types" tables in my DB, for example i have an User table and UserTypes table where User has an id or code of UserTypes, those "Types" tables are immutable through whole deployment time, and i would like hibernate to cache them, i mean cache whole table -> all access to those entities should be in-memory, wherether it's by some query, or by load or by whatever else, (<cache> in table mapping seems not to work, coz hibernate is still doing selects, and collection cache seems to be inappropriate here), some suggestions ?
thanks :)
Hin
Turn on hibernate logging (log4j.category.org.hibernate=DEBUG)
Look at cache hit entries for ehcache assuming you are using this.
Hibernate will cache both the queries (so you don't have to prepare them again) and the results.
On the ehcache.xml file you will need to add an entry for the class you want to cache, and make the cacheing "eternal".
The ehcache documentation explains how to do this.
Bear in mind if you change the data outside of the hibernate application the cache will not get refreshed.