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: conditional cascade
PostPosted: Thu Dec 09, 2004 3:29 pm 
Beginner
Beginner

Joined: Thu Dec 09, 2004 3:19 pm
Posts: 34
I've got a somewhat unusual problem. I have a class Foo which references a set of Bar objects. When the the system executes a run of "Foo", it copies the Foo object and it's associated set of Bar objects. This gives me a historical list of the objects at the time of the execution. The original Foo is my template, so to speak.

The problem comes on deletion. If I'm deleting a historical Foo I also want the delete to cascade the the Bar objects. The historical Bar objects have no meaning once their containing historical Foo is gone.

However, I do _not_ want my template Foo to delete it's associated Bar objects when it's removed. Many "template" Foo objects may reference the same common Bar objects (hence the purpose of the copy, I don't want changes to a main Bar object to affect historical versions of those objects).

I'm not sure how to map this. Basically, I want to have cascade="all" _except_ if it's a template instance. I tried having a FooTemplate subclass of Foo and overriding the Foo properties to not cascade for FooTemplate, but I can't seem to find a syntax that allows that.

The only other solution I can see is to have an entirely different table for FooTemplate, but that's rather messy as it ends up requiring entirely separate tables for the related set of Bar objects (and actually I have multiple sets of objects, so it really explodes the number of tables).

Any suggestions? Does the problem as described make sense?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 5:14 pm 
Beginner
Beginner

Joined: Thu Dec 09, 2004 3:19 pm
Posts: 34
For clarification, I want to do something like this. Note the cascade="all" in the main class, but not in the FooTemplate subclass.

Code:
<class name="FOO">
    <component name="subpiece">
      <set name="bars" cascade="all">
        <key column="FOO_ID"/>
       <many-to-many column="BAR_ID" class="Bar"/>
      </set>
    </component>

    <!-- For the template we don't want to cascade deletes -->
    <subclass name="FooTemplate">
      <component name="subpiece">
        <set name="bars">
          <key column="FOO_ID"/>
          <many-to-many column="BAR_ID" class="Bar"/>
        </set>
      </component>
    </subclass>
</class>


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.