insert and update default value for property differ from its documentation.


As per the documentation, the class <property> insert and update attributes are optional and their default value is true.

update, insert (optional - defaults to true) : specifies that the mapped columns should be included in SQL UPDATE and/or INSERT statements. Setting both to false allows a pure "derived" property whose value is initialized from some other property that maps to the same column(s) or by a trigger or other application.

But when we deserialize .hbm file to HbmClass whose property is not set (that means it should be true by default) it shows false value with the HbmProperty's insert and update. This contradicts the documentation. Actually it should have been true.

Here is the actual places where changes needs to be done.

As we know where to fix, so moderator will agree we can submit the solution.




Frédéric Delaporte
October 5, 2017, 11:46 AM

Your are welcome to contribute. Please make sure you follow guidelines from file. You already have the Jira, which is great.

About tests, there are already some tests about those properties, like WhenSetUpdateThenSetAttributes in NHibernate.Test.MappingByCode.MappersTests.PropertyMapperTest. So it seems some tests are missing, and need to be added.

About the classes, they are generated code. Avoid editing them manually. Instead follow How to generate Hbm.generated.cs.txt.

It should be noted that the actual feature provided by those update and insert attribute still works as expected even when they are not set, treating them as if they were true, because the feature checks if they were explicitly defined, and if no, disregards their actual value and considers them true.

Now for correctness it would still be better to have their default value correctly set in the xsd schema.




Sanjeev Sinha




Affects versions