Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ordering of entity properties in lazy loaded objects #3650

Unanswered
carl-berg asked this question in Q&A
Discussion options

Hi!

In some test projects where we use NHibernate/FluentNHibernate to map our domain model and using Verify to assert changes, we sometimes get inconsistent ordering of properties in the output. I created an issue in the Verify github repo: VerifyTests/Verify#1396, but I'm wondering if this is more of an NHibernate issue. The problem we experience is that the order of properties change sometimes and it seems it's when it happens, it's usually properties that are lazy loaded the might change place. This is a bit of a problem when using a serialized test framework like verify because it causes tests to become flaky. Here's an example from our build server which has generated a different output than on our development machines:

Image

... so basically I'm wondering if this is something that could be caused by NHibernate lazy loading? ...and if so, is there something to do about it, any settings that can be changed to make property ordering deterministic, aside from using NHibernateUtil.Initialize to ensure all lazy loaded entities have been loaded before asserting the object?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Lazy loading causes the entities to be loaded as proxies, in other word, as a subclass dynamically generated by NHibernate. So, if your test compare an instance your code has instantiated with a loaded one, they will not have the same class, so the serialization ordering of properties might change.

You must be logged in to vote
1 reply
Comment options

Thanks for the response @fredericDelaporte, my guess is that this is what was happening. So my next question, is there any way to make the ordering of properties deterministic? Any settings available or plug-ins possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #3648 on February 10, 2025 20:11.

AltStyle によって変換されたページ (->オリジナル) /