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