We're using NH 3.2 and Fluent NH. We've recently made a CLOB-backed
property lazy to ease a performance problem. In doing so, it has broken
the identity property of our entity. While the backing field in the proxy
shows the correct value,none of the proxy's properties for the identity
expose the right value. Here's a reduction of the code at play:
public class AbstractTemplate {
private int _id;
public virtual int Id { get { return _id; } }
public virtual TemplateId TemplateId { get { return new TemplateId(_id); } }
public virtual string Content { get; set; }
}
public class ConcreteTemplate : AbstractTemplate {
}
public class AbstractTemplateMap : ClassMap<AbstractTemplate> { // Fluent
NHibernate
public AbstractTemplateMap() {
Id(x => Id)
.UnsavedValue(0)
.Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore);
Map(x => x.Content)
.CustomType("StringClob")
.LazyLoad() // NOTE: This is a LAZY property!
.Access.Property();
}
}
ConcreteTemplate template = GetSession().Get<ConcreteTemplate>(17);
Log(template.Content); // I see my content!
Log(template.Id); // I get 0, but debugger shows
ConcreteTemplateProxy._id == 17
Log(template.TemplateId); // I get 0, but debugger shows
ConcreteTemplateProxy._id == 17
As soon as we remove ".LazyLoad()" from the content property, the Id
properties work fine.
Now I've explored this group and JIRA and found several bugs with lazy
properties, but from reading them, I don't think any of them are *this*
problem. Here's the bugs I've read:
- NH-3058 <https://nhibernate.jira.com/browse/NH-3058> - Methods on
entities with lazy properties do not trigger load of lazy properties
- NH-2632 <https://nhibernate.jira.com/browse/NH-2632> - Lazy Properties
Causing An Exception If Containing Class Is Set To Not Lazy
- NH-2638 <https://nhibernate.jira.com/browse/NH-2638> - Id Property
With Private Setter Not Set With Lazy Classes
- NH-2772 <https://nhibernate.jira.com/browse/NH-2772> - Lazy-collection
not loaded when a property is Lazy-loaded
I'm going to contiune testing, maybe make a standalone sandbox project,
etc. But i wanted to drop a line here at the same time with the hope that
someone else might know more.
Thoughts?
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/AeOdcORJalYJ.
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.