Hi,
I am implementing some logic in my domain that ensures that one of my objects has a unique value in one of its properties, e.g. Customer.SocialSecurityNumber.
During the update of a Customer object, I trigger various pieces of validation logic, however, when I execute an NH query of the DB to make sure that there are no other customers in the DB with the same SocialSecurityNumber, I get an exception due to a unique constraint in the DB.
I figured out that this was due to the default auto flush behaviour in NH and I can change this by setting the FlushMode on the session to Commit instead of Auto. However, I am not sure of the implications of doing this and am wondering if I should only set it for this one query and then flip it back to Auto after the query executes.
Any guidance appreciated.
Thanks,
Jason
|