-->
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: Cascading with mapped composite-id containing a class?
PostPosted: Sun Feb 11, 2007 8:02 pm 
Newbie

Joined: Sat Feb 10, 2007 10:19 am
Posts: 1
Location: Vienna
Hi everybody,

I have a class which uses a mapped composite identifier:

Code:
<class name="org.checkdisc.scan.SEFile" table="FILES">
   <composite-id class="org.checkdisc.scan.FileIdentifier" mapped="true">
      <key-many-to-one name="filename" class="org.checkdisc.scan.Filename"/>
      <key-property name="lastModified" type="timestamp"/>
   </composite-id>

   ...

</class>


My problem is that when I save() a new instance of SEFile, of which the "Filename" of the identifier is not yet persistent, I want the instance of Filename to be made persistent as well (before the SEFile itself is made persistent, the other way around it wouldn't work because of the foreign key constraint). Usually I would achieve this with cascade="create", but this parameter is not available for key-many-to-one. (I guess this is one of the limitations mentioned in the FAQ/Advanced Problems?)

A usual workaround is to replace the key-many-to-one with a key-property and add another many-to-one outside the composite-id (and add the cascade-option there), but I can't see how this could work because the key-property is not a simple type but a class (Filename)? The Filename mapping looks like this:

Code:
<class name="org.checkdisc.scan.Filename" table="FILENAMES">
   <id name="id">
      <generator class="native"/>
   </id>
   <property name="filename"/>
</class>


Any ideas how to achieve the cascading create? I'm using Hibernate 3.2.2. Thanks in advance!
Kevin


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.