Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
1.2.1
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Skolplatsen.Core" namespace="Skolplatsen.Core.Domain">
<class name="Elev" table="Elev" dynamic-insert="true" dynamic-update="true" >
<id name="ID" type="System.Int32" column="Id">
<generator class="identity"/>
</id>
...
<bag name="ElevVals" table="Elev_Val" inverse="false" lazy="true" cascade="all-delete-orphan" batch-size="10">
<key column="Elev_id" />
<one-to-many class="ElevVal"/>
</bag>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Skolplatsen.Core" namespace="Skolplatsen.Core.Domain">
<class name="ElevVal" table="Elev_Val" dynamic-insert="true" dynamic-update="true" >
<composite-id name="ID" class="Skolplatsen.Core.Domain.ElevVal+DomainObjectID">
<key-property type="System.Int32" name="Elevid" column="Elev_id" />
<key-property type="System.Int32" name="Kurskatalogid" column="Kurskatalog_id" />
</composite-id>
<property name="Prioid" column="Prio_id" type="System.Int32" not-null="true" />
<property name="Tilldelad" column="Tilldelad" type="System.Boolean" not-null="true" />
<many-to-one name="Elev" column="Elev_id" class="Elev" update="0" insert="0" />
<many-to-one name="Kurskatalog" column="Kurskatalog_id" class="Kurskatalog" update="0" insert="0" />
<many-to-one name="Prio" column="Prio_id" class="Prio" update="0" insert="0" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
IElevDao elevDao = new NHibernateDaoFactory().GetElevDao();
Elev elev = elevDao.GetById(12672, false);
elev.ElevVals.RemoveAt(0);
elevDao.SaveOrUpdate(elev);
elevDao.CommitChanges();
Full stack trace of any exception that occurs:
An exception is thrown saying that it isn't possible to complete UPDATE with setting the column Elevid to NULL in the table Elev_Val.
Name and version of the database you are using:
sqlserver 2005
Is this expected behavior? Why is an update statement issued?
/Regards