Hello.

I'm trying to migrate an app from NHibernate 1.x to 2.1, and I've noticed
something odd: my immutable objects are being deleted in my integration
tests.

For example, this test used to pass:

[Test, ExpectedException(typeof(NHibernate.HibernateException))]
public void DeleteExistingInstanceThrows()
{
        // Note: NHib transaction is opened/rolled back in test
setup/teardown
        m_testRecordId = CreateRecordInDB();
        var dao = new NHibFactory().GetTransDao();
        var obj = dao.GetById((long)m_testRecordId, false);

        dao.Delete(obj);
        dao.CommitChanges();

        Assert.IsFalse(TestRecordExists(m_testRecordId));
}

The call to CommitChanges should throw, because of trying to delete an
instance whose type is mapped with mutable="false". However, after updating
the expected exception type, this test now fails (because no exception is
thrown). I've checked the database and traced through the test, and the
record is created, the instance is loaded, and the record gets deleted again
afterwards.

The class in question is mapped to the same table as another class - it is
more-or-less intended as a read-only view of a subset of that data. Here's
the class mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
        <class name="Sample.Trans, Sample" table="tblTrans" mutable="false">

                <id name="Id" column="transId" unsaved-value="0">
                        <generator class="identity" />
                </id>

                <property name="Amount" column="amount" type="Decimal" />

                <!-- ...a half dozen other mapped fields... -->
        </class>
</hibernate-mapping>

I expect I'm missing something basic, but I've been scouring the web for any
reason why the mutable attribute might be ignored, and I've come up empty.

Regards,

Remi.

 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to