I have a solution.
For those who are interested the mechanism in this post has a few flaws but works in principal.
To make it work effectively you need to recursively add aliases as above but avoiding the dots in the alias name and reference the next createAlias association path with the alias name created prior. The hibernate Criteria will only accept one stage of an alias path at a time, it does this by pulling off the bean string before the FIRST dot (if there is one) so multi-level dotted paths will fail if they're attempted in one step.
i.e. the code in the original post would become something like:
createAlias("mtoSomeOtherObject", "sooAlias1");
createAlias("sooAlias1.sooSomeOtherObject_2", "sooAlias2");
createAlias("sooAlias2.sooSomeOtherObject_3", "sooAlias3");
and the expression becomes.
criteria.eq("sooAlias3.soo3ID", <some id value>);
You need also to ensure the alias name doesn't grow larger than 30 characters for most databases as these aliases are used directly in the sql and will cause an error if they're too large.
Regards
sasco
|