This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Entities and their relations load fine when they're loaded for the first time (from db, not from cache). But once they're in level II cache, subsequent loads lead to null references for their relations.
For example, I have two entities: WeightUnit and Weight (one-to-many relationship).
The code above executes fine when it runs for the first time, Weights are loaded from the db since they're not yet cached. However, when the same code is executed for the second time (read from cache), it throws "Object reference not set to an instance of an object" on the second line. WeightUnit is null. Why is this so? Even if I load all the WeightUnits into cache, I still get the same error. Please help. |
|
|
Cached entities should always have lazy loaded associations (only the initial database fetch will be eager if applicable) but if the associated entity in cache this should just be a cache hit on lazy load. Ive tried constructing a repro based on your description above but this is working correctly here (association is always lazy on returning from cache which then triggers a lazy load on WeightUnit which is also fetched from cache when traversing. Are you able to send us through a small repro project which triggers this and I can debug this further for you.
|
|