-->
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: Dereference values from collection
PostPosted: Mon Jul 11, 2005 1:20 pm 
Newbie

Joined: Mon Jul 11, 2005 4:35 am
Posts: 7
Hi

I've a one-to-many relationship Order and the OrderItems contained in
the Order. The Order class contains a Set with OrderItems.

When I update the Order I want to dereference OrderItems which has
been removed. An extract of the configuration file is shown below.

<set name="orderItems"
inverse="true"
cascade="all-delete-orphan">
<key column="ORDERS_ID"/>
<one-to-many class="model.OrderItem"/>
</set>

When I in code try to make the Set empty the OrderItems are still left.
My code is like this

Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
order.setOrderItems(new HashSet());
session.update(order);
tx.commit();
HibernateUtil.closeSession();

But the OrderItems are still left in the database. How am I to do to
get the dereferenced OrderItems removed?


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.