.net - Nhibernate Update does not persist change to database -


i have problem getting change(s) data object retrieved using nhibernate persist database. no exceptions it's difficult know look. suggestions?

string name = "somenewname"; string repositoryid = "somerepositoryid";  isession nhbsession = getnhbsession(session); nhbsession.transaction.begin(); try {     repositorydto existingrepository = nhbsession.get<repositorydto>(repositoryid);     if (existingrepository == null || existingrepository.timedeleted != null)         throw new exception("repository not exist in system or deleted. cannot modify.");      existingrepository.name = name; //works fine here expected; in db old name     nhbsession.update(existingrepository);     nhbsession.transaction.commit(); } catch (exception ex) {     nhbsession.transaction.rollback();     throw new exception("error modifying repository: " + ex.message, ex); }   <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="somecomponent"   namespace="somecomponent.repository.dto" auto-import="true" default-lazy="false">   <class name="repositorydto" table="repository" mutable="false">       <id name="repositoryid" column="repositoryid" unsaved-value="0">       <generator class="assigned"/>     </id>     <property name="systemid" column="systemid" not-null="true" />     <property name="timecreated" column="timecreated" not-null="true" />     <property name="timedeleted" column="timedeleted" not-null="false" />     <property name="name" column="name" not-null="true" />   </class> </hibernate-mapping> 

you're missing flush:

// etc... nhbsession.update(existingrepository); nhbsession.flush(); nhbsession.transaction.commit(); // etc... 

more: committing database transaction


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -