-->
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: Removing object from collection
PostPosted: Fri Aug 17, 2007 6:51 am 
Newbie

Joined: Mon Mar 05, 2007 4:38 am
Posts: 17
Hi all,

this is probably easy but I can't work it out. I have the following mapping:

Code:
  <class name="Company" table="Customers">
    <id column="CompanyID" name="id"/>
    <set name="environments" sort="unsorted" table="CustomerEnvironments" lazy="false" batch-size="3">
      <key column="CustomerID" not-null="true"/>
      <one-to-many class="Environment"/>
    </set>
  </class>
  <class name="Environment" table="CustomerEnvironments">
     <id column="ID" type="long" name="id" access="field">
       <generator class="identity"/>
    </id>
    <property column="Environment" name="name" access="field"/>
  </class>


I first retrieve a company and it contains 3 environments. I then add 2 new environments and remove all 3 old environments.

After a session.update(company) and a commit, the new environments are added to the database, but those I had removed are still present in my database table.

Do I miss a mapping setting or something here?

Thanks,
Steven


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 17, 2007 7:04 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
You're just removing the association between company and environment, not deleting the environment objects themselves. If you want the environments to be deleted when removed from the company then either delete them explicitly or specify cascade="delete-orphan" on the company->env mapping.


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.