Hello,
I need to create a conditional many-to-one statement to create the following link: TABLE1.FK = TABLE2.ID when TABLE1.COND=0
Using the following wouldn't work because the column COND exists in TABLE1.
Code:
<class name="TABLE2" table="TABLE2" where="..."
Another alternative would be using the <any> syntax. However the <any> statement has limitations: property-ref="...." couldn't be used with it (in my case TABLE2.ID is not the primary key of the table)
Code:
<any name="TABLE1" id-type="..." meta-type="int">
<meta-value value="0" class="TABLE2"/>
<column name="COND"/>
<column name="FK"/>
</any>
A third alternative (which still doesn't fit my purpose) is to use the "formula" tag. However, I would loose a lot of functionalities in my application as the "formula" syntax removes the "column" field.
Code:
<many-to-one name="TABLE1" class="TABLE1" formula="case when COND=0 then FK end"/>
Isn't there any simple syntax that can do the job, something like:
Code:
<many-to-one name="TABLE1" class="TABLE1" where="COND=0"/>