开发者

NHibernate difference between nosetter and field access strategies

I originally posted about a problem where NHibernate was issuing an additional query for a collection that was exposed as a ReadOnlyCollection and mapped as "nosetter" or "ReadOnlyPropertyThroughCamelCaseField" in FluentNhibernate.

The property was not being accessed directly in my code but NHibernate thought there was a change. When I changed the access strategy to "field" - or "CamelCaseField" in fluent nhibernate, it fixed the issue.

So my question is, what 开发者_JAVA百科is the difference between the two access strategies in how NHibernate detects changes to a collection?

Thanks Ben


field: NHibernate will access the field directly. NHibernate uses the value of the name attribute as the name of the field. This can be used when a property's getter and setter contain extra actions that you don't want to occur when NHibernate is populating or reading the object. If you want the name of the property and not the field to be what the consumers of your API use with HQL, then a naming strategy is needed.

nosetter: NHibernate will access the field directly when setting the value and will use the Property when getting the value. This can be used when a property only exposes a get accessor because the consumers of your API can't change the value directly. A naming strategy is required because NHibernate uses the value of the name attribute as the property name and needs to be told what the name of the field is.

source: http://nhibernate.info/doc/nh/en/index.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜