-->
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.  [ 2 posts ] 
Author Message
 Post subject: Deleting collections
PostPosted: Wed Feb 07, 2007 5:26 am 
Newbie

Joined: Sat Feb 03, 2007 12:57 pm
Posts: 2
I have this mapping file


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="GS.Catalog.Item,GS.Catalog" table="gsc_Item" lazy="true">

   <id name="Id" column="id" type="String">
      <generator class="assigned"/>
   </id>
      ....
    <set name="Categories" table="gsc_Categorization">
      <key column="itemId"/>
      <many-to-many column="categoryId" class="GS.Catalog.Category, GS.Catalog"/>
    </set>
   </class>
</hibernate-mapping>


So, if I do item.Categories.Clear() it will not delete categories for this item.
Code:
public override void DeleteItemCategories(string id)
        {
            ISession session = NHibernateHelper.GetCurrentSession();
            ITransaction tx = session.BeginTransaction();
            Item item = (Item)session.Get(typeof(Item), id);
            item.Categories.Clear();
            session.Update(item);
            tx.Commit();
            NHibernateHelper.CloseSession();
        }

What is solution?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 5:07 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Try flushing your ISession

_________________
If this helped...please remember to rate it!


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

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.