Mapping a private field without property getter fails: new in NH 3.1.0.4000

285 views
Skip to first unread message

Oliver Friedrich

unread,
Mar 17, 2011, 6:23:47 PM3/17/11
to nhu...@googlegroups.com
Hi all, I'm having the following problem with version 3.1:

I used to map the private fields of a certain class
private int_positiveValue;
private int_negativeValue;

using the following hbm.xml:

<property name="PositiveValue" access="field.camelcase-underscore" />
<property name="NegativeValue" access="field.camelcase-underscore" />

This worked fine with NH <= 3.0, but with 3.1.0.4000 I get an error while building the session factory:

[PropertyNotFoundException: Could not find the property 'PositiveValue', associated to the field '_positiveValue', in class '...UsefulnessEntry']
   NHibernate.Properties.FieldAccessor.GetGetter(Type theClass, String propertyName) +248
   NHibernate.Util.ReflectHelper.ReflectedPropertyClass(String className, String name, String accessorName) +131
...

[MappingException: Could not compile the mapping document: ...UsefulnessEntry.hbm.xml]
...

I did not have any property getters defined for my private fields. Now it seems to be forced by NH 3.1. When I add them as follows the error vanishes:

private intPositiveValue { get { return _positiveValue; } }

private intNegativeValue { get { return _negativeValue; } }
I would consider this a regression and I'm wondering if this is by design or by accident. Can anybody shed light on this new behaviour?
Cheers, Oliver
_____________


---  Eulers Identität ---

Roger Kratz

unread,
Mar 18, 2011, 8:34:05 AM3/18/11
to nhu...@googlegroups.com

http://216.121.112.228/browse/NH-2556

 

If you don’t have any property, map it using access=”field”.

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

Fabio Maulo

unread,
Mar 18, 2011, 12:29:33 PM3/18/11
to nhu...@googlegroups.com
This mapping
<property name="PositiveValue" access="field.camelcase-underscore" />
mean:
For my property named "PositiveValue" you (NH) have to access to the field; to discover which is the associated field you (NH) have to use the strategy "camelcase-underscore".

If there is no property you can't use the accessor with a specific strategy.

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.



--
Fabio Maulo

Fabio Maulo

unread,
Mar 18, 2011, 12:30:54 PM3/18/11
to nhu...@googlegroups.com
Note: you property does not have to be public.
--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages