J'ai un problème pour obtenir ma modification (s) à l'objet de données extrait en utilisant NHibernate pour persister dans la base de données. Je ne reçois aucune exception, il est donc difficile de savoir où regarder. Aucune suggestion?La mise à jour de Nhibernate ne persiste pas la modification de la base de données
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 does not exist in system or is deleted. Cannot modify.");
existingRepository.Name = name; //works fine up to here as expected; is in DB with 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>
Lol ... tellement vrai. – rebelliard