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: many-to-many collection issue...
PostPosted: Wed Oct 28, 2009 10:55 pm 
Newbie

Joined: Wed Oct 28, 2009 10:37 pm
Posts: 1
Wondering if anyone has any tips on this...

I have a Product table, and a Component table. Component is subclassed, with discriminator ComponentType. Have a ProductComponent table which is many-to-many

In my product mapping, I created bags of components
Code:
<bag name="Widgets" table="ProductComponent">
    <key column="ProductId" />
    <many-to-many class="Widget" column="ComponentId" where="ComponentType=1" />
</bag>
<bag name="Gizmos" table="ProductComponent">
    <key column="ProductId" />
    <many-to-many class="Gizmo" column="ComponentId" where="ComponentType=2" />
</bag>


This works, except for when I need to clear, or mostly clear my collection from the Product. In that situation, a single delete command is issued. DELETE FROM ProductComponent WHERE ProductId=@p0. Then it re-inserts the new ones, but has deleted all the existing collections that didn't get updated.

It seems like in order to get the Delete statement to include the ComponentType, I'd need to put a where on the bag, but that wants a ComponentType on the association table then.

Anyone have any ideas on how to better accomplish this?


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.