Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:45:00+00:00 2026-05-26T22:45:00+00:00

I have some big data objects, stored in CompressedData property, so I don’t want

  • 0

I have some big data objects, stored in CompressedData property, so I don’t want to load this data every time, when I do any query. So I tried to mark this property as LazyLoad() in mapping class.
There is no access to CompressedData out of entity class, because I have UncompressedData property that give me functionality of compress/decompress data. So I call CompressedData only inside TestEntity class.
But I got a trouble. NHibernate 3.2.0.4000 (or FluentNHibernate 1.3.0.717) didn’t want to load LazyLoad property if there are no requests to this property out of entity class. If try to run test, I will got an empty string.

public class TestEntity {
    public TestEntity(){}
    public TestEntity(string otherData, string dataForCompress){
        OtherData = otherData;
        UncompressedData = dataForCompress;
    }

    public virtual string OtherData {get;set;}        
    public virtual byte[] CompressedData {get;set;}
    public virtual string UncompressedData {
        get {
            return SomeLongFunctionForDecompress(CompressedData);
        }
        set {
            CompressedData = SomeLongFunctionForCompress(value);
        }
    }
}

public class TestEntityMapping : ClassMap<TestEntity> {
    public TestEntityMapping(){
        Map(OtherData);
        Map(CompressedData).LazyLoad();
    }
}

[Test]
public void can_readLazyLoadedProperty(){

    TestEntity obj1 = new TestEntity("test","long data here");
    using (nHibernateHelper.CreateNewSession(){
        Session.Save(obj1);
    }
    using (nHibernateHelper.CreateNewSession(){
        TestEntity obj2 = Session.Get(obj1.Id);
        //byte[] data1 = obj2.CompressedData;
        string data2 = obj2.UncompressedData;
        Assert.AreEqual("long data here",data2);   
    }            
}

But if uncomment byte[] data1 = obj2.CompressedData; line all works fine. Maybe I need add some attribute to CompressedData property or add some properties to mapping?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:45:00+00:00Added an answer on May 26, 2026 at 10:45 pm

    I suppose .NET gives similar mechanism as Java, and from your description it seems to be that way:

    Hibernate modifies entity classes wrapping them in its own objects, that modify getters so that LazyLoad is working

    Calling getters from inside you call unmodified version of getters, which do not handle LazyLoad.

    So this what you get is feature, not bug. The solution could be moving logic outside entity, that should have fields and accessors only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data structures: all_unordered_m is a big vector containing all the strings
I have a big chunk of HTML which is a template for some data
I have webRole with some data stored in Session. The data is some tens
I have a big project compiled into libProject.so-file (shared library), I made some modules
I have written a relatively big insert statement, and some of the fields are
I'm here to get some information. We have a product thats pretty big and
well, i have a big file, there are some contents i needed to be
I have some files stored at amazon. all in private mode, and since I
I have some code where I really want to call a virtual method from
I have some code that roughly does this inside of a GAE worker task:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.