I'm trying to enable lazy-loading of a Property in one of my entities, but I keep running into trouble.
Explanation of problem: I have an Image-class that contains info about an image, filename, size, type etc, including binary data of the object. Since the binary data can become huge, I need to be able to load the image without that data unless explicitly addressed. Since you cannot specify Lazy on a property, I needed another solution to the problem. First idea was to use a Nested class, but that however doesn't support Lazy either. Second idea was to use a OneToOne relation, but that doesn't support Lazy either. Third idea, found here: http://gnschenker.blogspot.com/2007/06/one-to-one-mapping-and-lazy-loading.html, when using OneToOne with a BelongsTo gives the possibility to add Lazy to the BelongsTo, however I don't get this to work. I can't seem to get my head around this Lazy-loading. This is my setup: [ActiveRecord( "`product`", "products")] public class Product { [HasAndBelongsToMany( typeof( Image ), Lazy = true, Inverse = false] public virtual ISet<Image> Images {} } [ActiveRecord( Lazy = true )] public class Image { [PrimaryKey( PrimaryKeyType.Native)] public override int Id { get; set; } private ImageData data; [BelongsTo(Lazy = true)] public virtual ImageData Data { get { return this.data; } set { value.Image = this; this.data = value; } } } [ActiveRecord( Lazy = true )] public class ImageData { [PrimaryKey( PrimaryKeyType.Foreign )] public virtual int Id { get; set; } [OneToOne( Constrained = true )] public virtual Image Image { get; set; } } The code is heavily simplified, but this setup gives me: NHibernate.Id.IdentifierGenerationException: null id generated for: ImageData If I try to use OneToOne on both Entities (Image and ImageData) it seem to work, but Lazy doesn't work. Another weird issue is that when having the Images-collection on Product set to Lazy, it still doesn't generate proxy-objects of Images, I thought that was the primary goal with Lazy? Where can I find some useful guides regarding Lazy-loading that can explain it in detail? Even Lazy on my ImageData-class doesn't seem to make any difference, I would assume that having OneToOne on everything, then Lazy on ImageData would generate proxy-object, but that doesn't seem to be the case. // Jimmy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
