Hibernate 排序&关联查询。 200散分求助。 另开贴给分
目前有table1 &table2 两个表。table1的主键是table2的外键也是table2的主键。
table1 有字段 f1,f2,f3.
table2 有字段 z1,z2,z3. z1是table2的主键
我现在想实现按照 z3来排序 table1的内容。用sql我的写法是:
1、select * from table1 where f2= '1' oder by ( select z3 from table2 where table2.z1 = table1.f1)
2、seelct * from table1 t1,table2 t2 where t2.z1(+) = t1.f1 order by t2.z3.
两种写法都能在plsql执行。但是写成对应的hsql如下
1、from Table1 as table1 where table1.f2 = '1' order by (select table2.z3 from Table2 as table2 where table2.z1 = table1.f1)
执行结果报错是 缺少右括号。
2 方式取值出来我不知道对象是什么类型的。无法造型,既不是table1 也不是table2
求助,,,该问题如何处理。我用的hibernate2的版本。