cache configuration x 3

18 views
Skip to first unread message

Throckmorton

unread,
Jul 11, 2012, 9:14:04 PM7/11/12
to nhu...@googlegroups.com
In NH3.0, there are three ways of configuring the cache on entities:

1. in the mapping file
2. in the configuration xml settings
3. in code using the Configuration object

Is there an order of precedence for these different options? If I have read-write caching configured
in the mapping file, and then I set read-only caching in code, which setting does NH use?

Jason Meckley

unread,
Jul 12, 2012, 7:26:01 AM7/12/12
to nhu...@googlegroups.com
IIRC it goes:
1. configuration
2. mapping overrides configuration
3. code overrides mappings

this is driven by 2 concepts
1. general/broad to specific: configuration file acts like a "catch all " or default setting. this can then be overridden for specific entities/queries in the mappings
2. order of operations: 1st the configuration is loaded, then the mappings. now you have a configuration object you can manipulate prior to creating the session factory.
Reply all
Reply to author
Forward
0 new messages