-->
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: <any> and fk constraint violation
PostPosted: Thu Jun 07, 2007 9:06 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
Hi all,

I mapping some review to targets (reviewables) whose classes are not known in advance, that is, they're supposed to be extensible. So the reference to target is mapped as an <any> association, consisting of a kind and an id. So far so good. The problem comes when mapping the inverse relationship target *---> review. Here the schema updater generates a fk constraint for each target kind, so when I add some review to any of them, the constraints for the others are violated. I would like to avoid this constraint generation, it's ruining automatic schema update, which is quite valuable for my team, specially for testing purposes. Is it possible to do this? Or is there any reasonable way to achieve the same kind/id sort of fk another way? I tried filtering with @Where for the right types, but the fk violation remains there.

Here are some tentative mappings:
Code:
  <class name="any.Review" > 
    <id name="id"><generator class="native" /></id>   
    <any name="target" meta-type="string" id-type="int">
      <meta-value value="A" class="any.TargetA"/>
      <meta-value value="B" class="any.TargetB"/>
      <column name="target_kind"/>
      <column name="target_id"/>
    </any>
  </class> 

  <class name="any.TargetA" > 
    <id name="id"><generator class="native" /></id>
    <set name="reviews" cascade="all" access="field">
      <key><column name="target_id"/></key>     
      <one-to-many class="any.Review"/>   
    </set>
  </class>

  <class name="any.TargetB"> 
    <id name="id"><generator class="native" /></id>   
    <set name="reviews" cascade="all" access="field">
      <key><column name="target_id" /></key>
      <one-to-many class="any.Review"/>   
    </set>
  </class>


Thank you in advance
Cheers,
Carlos


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.