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.  [ 4 posts ] 
Author Message
 Post subject: how to set up computed relations?
PostPosted: Mon Feb 27, 2006 6:55 pm 
Newbie

Joined: Mon Feb 27, 2006 6:47 pm
Posts: 8
I have two tables (TA and TB) that are related logically by one text field TA.ref_field. I created a Java class for each table and would like to setup a property on my class for TA that points to an instance of my java class for TB based on tb.id = substr(ta.ref_field, 1,2) ... is this possible?

I've read about formulas and seems this may be the option but I don't really understand how to use them...any suggestions?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 12:01 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes, formulae are the way to go. Set up your association in the normal way, and use "formula="(substr(ref_field, 1, 2))" instead of "column="...". This won't work if there are two ref_fields in the result set (e.g. if you've got a join on the ref_field column), but if ref_field only occurs once then it'll do what you want.


Top
 Profile  
 
 Post subject: Beautiful...It works!!!
PostPosted: Tue Feb 28, 2006 12:21 am 
Newbie

Joined: Mon Feb 27, 2006 6:47 pm
Posts: 8
Thanks this was very helpful. My association now works.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 12:30 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Then you'll have to click the "yes" link on my helpful post!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.