-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: One to many issue
PostPosted: Sun Jan 06, 2008 5:18 pm 
Newbie

Joined: Sat Sep 22, 2007 5:42 am
Posts: 10
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.