Id Property With Private Setter Not Set With Lazy Classes
Description
Environment
Attachments
Activity
Ricardo Peres April 12, 2011 at 6:46 AM
Using Castle bytecode provider it works fine, except that lazy properties crash even in lazy entities.
I would say that the problem is with the new bytecode provider.
Ricardo Peres April 11, 2011 at 4:40 AM
Fabio,
There is no difference. The mapping by code is working well. That is not the problem, you have done an excellent job in that.
The problem I am having seems to me related with lazy entities. is the same, I think.
If you have time, and interest, please check my demo project: http://cid-0450c015fc418de2.office.live.com/self.aspx/.Public/NHTest.zip. I may be doing something wrong, but I don't think so... I have always (since .NET 3.5, that is) used auto properties, even for ids, and I never had this problem. It is not critical to me, so if you have more urgent things do do, it's fine by me! I only wished I had confirmation from someone else that there is a problem.
Thanks!
Fabio Maulo April 11, 2011 at 4:27 AM
And which is the difference between the mapping through XML and the XML of the mapping by-code ?
To see the XML you can use:
var mapping = mapper.CompileMappingForAllExplicitAddedEntities();
Console.WriteLine(mapping.AsString());
Ricardo Peres April 11, 2011 at 3:59 AM
Test project is here: http://cid-0450c015fc418de2.office.live.com/self.aspx/.Public/NHTest.zip.
Ricardo Peres April 11, 2011 at 12:51 AM
Fabio,
No, I don't: I have specified all five of them (Field, Property, None, NoSetter and ReadOnly), you can try it yourself. The property is never set.
It does work if mapped through hbm.xml, without any problems. It the class is not lazy, then I don't even need to specify the accessor.
When I have a class with a private id setter, if the class is lazy, then the id is not set.
No exception occurs, it simply is not set. Mapping is done with the new mapping by code.
Tested with the trunk version, as of 00:00.