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.  [ 2 posts ] 
Author Message
 Post subject: Table Name Substitutions in Formulas
PostPosted: Fri Jun 24, 2005 8:18 pm 
Newbie

Joined: Wed Jun 22, 2005 6:33 pm
Posts: 8
I'm writing a subselect formula to use as a discriminator. I understand that formulas are written in pure SQL, not HQL. So, here's essentially what I'm trying to write...

Code:
(SELECT Inner.Name FROM Inner WHERE Inner.ID = Outer.ID)


This is of course a simplified example. The "Outer.ID" is the field that is outside the subselect.

Here's the problem... When writing the SQL, Hibernate aliases the table names. In this case, "Outer" could become "Outer0_". This name appears to be unpredictable.

So how can I write a subselect using values from the outer query? Using MySQL, it appears the only way is to refer to the outer table by name.

Any ideas?

Thanks

Norman


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 26, 2005 3:48 pm 
Newbie

Joined: Mon May 30, 2005 10:26 am
Posts: 13
Just a hunch. If you need to refer only Outer.ID and not other Outer.* fields, try to embed the whole thing in an association, and place the formula within this association.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.