How to do Cache mappings by R4R Team

We have given the simple cache code to understand the cache mapping. In the <cache> element of a class or collection mapping has the following form:


<cache 

    usage="transactional|read-write|nonstrict-read-write|read-only"  

    region="RegionName"                                              

    include="all|non-lazy"                                           

/>


Tag description is given below:


Tag

Description

usage(required)

It specifies the cache strategy. In transactional,read-write, nonstrict-read-write or read only

region(optiona)

Defaults to the classes or collection role name.

It specifies the name of the second level cache region.

include(optional)

It defaults to all.It work non-lazy. It speficies that properties of teh entity mapped with lazy=”true” can not be cached when attribute-level lazy fetching is enabled.


We can specify <class-cache> and <collection-cache> elements in hibernate.cfg.xml.The usage attribute specifies a cache concurrency strategy.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!