During page: - I get an object
If you get an object from a session, you misunderstand Update. The update is intended to join an existing object to the session. If you get an entity from a session, it is already tied to that session, so updating does not make sense.
SaveOrUpdate vs. Update in this case does not matter - the same.
NHibernate tracks object changes in a session. When you make a transaction or clear a session, it checks for any changes (which are), and then commits them to the database. The thing is that it's not your job to keep track of which objects are changed (dirty), these are NHibernates.
Other ORMs may require that you yourself track changes and invoke some update explicitly on any changed object that you want to save, but NH does not work that way.
So, to answer your question, if the verification fails, you do not want to complete the transaction.
NH is also fixed in relation to the unit of work pattern. Therefore, if you are committing to another logical part of the program from your business logic, which checks the operation, this is likely to cause friction.
anonymous
source share