-->
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: Conditional many-to-one
PostPosted: Fri Jul 03, 2009 5:08 am 
Newbie

Joined: Fri Jul 03, 2009 4:20 am
Posts: 1
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"/>


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.