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