-->
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: Updating using collections
PostPosted: Tue Jul 15, 2008 4:06 pm 
Newbie

Joined: Tue Jul 15, 2008 3:55 pm
Posts: 5
This is jus Sample which resembles with my actual tables..

Table A
f1 int
f2 int FK(References BF1 of Table B)

Table B
BF1 int
BF2 int ( References to Table A f1)


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

<class name="EntityTableA" table="TableA" >
<id name="f1" column="f1" type="System.Int32" unsaved-value="0">
<generator class="identity" />
</id>

<bag name="coll_f2" cascade="all" lazy="false">
<key column="f1"/>
<one-to-many class="EntityTableA"/>
</bag>
</class>
</hibernate-mapping>


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="BF1" table="TableB" >
<id name="BF1" column="BF1" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<property name="BF2" column="BF2" type="Int32" length="4" />
</class>
</hibernate-mapping>

Question:
When i load "EntityTableA" am getting the data and it is working fine but when i update collection(EntityTableB) using following code it is throwing error.

ICriteria criteria = _session.CreateCriteria(typeof(EntityTableA));
criteria.Add(NHibernate.Expression.Expression.Eq("f1", 1));
EntityTableA dPop = new EntityTableA();
dPop = (EntityTableA)criteria.List()[0];
dPop.EntityTableB = null; // -- Here am making Table B entity as null
_session.SaveOrUpdate(dPop);


please help me..


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.