Try disable lazy loading for the class. 2009/3/30 Anne Epstein <[email protected]>
> > At least as far as 2.0.1 goes, if you're using lazy loading for a > mapped class, everything public in the class needs to marked as > virtual, regardless of access settings. That includes all properties, > including properties not mapped at all, and any methods as well. > Reason is roughly that NHibernate wants to make a complete proxy, and > can't do that if it can't override everything in the class. > > > > On Mon, Mar 30, 2009 at 12:53 AM, Enrique Ramirez <[email protected]> > wrote: > > > > Good day, > > > > I'm having an issue where I'm trying to map a private member of a > > class which happens to have a non-virtual public setter Property. I > > noticed that even if I set the access="field" attribute in the > > property tag in the mappings file, as long as NHibernate sees my > > public setter property, it gives an InvalidProxyTypeException. If i > > make my setter property private or virtual public, then everything > > works as planned. > > > > I'm curious though, isn't NHibernate supposed to ignore properties if > > I specify access="field"? I also tried nosetter and got the same > > behavior. Also tried specifying the name strategy and same result. > > > > Code snippets below: > > > > Mapping: > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > assembly="DomainModel" namespace="DomainModel"> > > <class name="Test" table="test" lazy="true" proxy="Test"> > > <id name="id" column="id" type="int" > access="field.lowercase-underscore"> > > <generator class="sequence"> > > <param name="sequence">test_id_seq</param> > > </generator> > > </id> > > <property name="_problematicfield" column="problematicfield" > > type="string" length="50" access="field" not-null="true" /> > > </class> > > </hibernate-mapping> > > > > Class: > > public class Test > > { > > public Test () {} > > > > private int _id; > > private string _problematicfield; > > > > public string ProblematicField > > { > > set > > { > > _problematicfield =DoSomethingInteresting(value); > > } > > } > > } > > > > -- > > ------------------------------------------------------------------ > > Enrique Ramirez Irizarry > > Lead Developer, CodaBytes Consulting Group > > http://www.Codabytes.com > > Personal Page: http://www.indiecodelabs.com > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
