我有一个复杂的 HQL 查询。
我想访问 Oracle 特定的rownum列值作为我返回结果的一部分。如何编写查询(和/或更改我的 hbm.xml)以支持此功能?
到目前为止我尝试过的方法不起作用:
修改我的 hbm.xml
<property name="rownum" type="int" update="false" insert="false" generated="never"/>
和一个查询,例如:
"select dog.rownum from Dog as dog where ..."
但我得到java.sql.SQLException: ORA-01747: invalid user.table.column, table.column, or column specification
我怀疑我可能需要将一些 sql 与我的复杂 hql 查询混合在一起......欢迎提出建议。谢谢。
一些背景:
- http://ronfrancis.wordpress.com/2007/10/16/dont-forget-an-order-by-for-pagination-queries/
- hibernate 使用 oracle 的 rownum 'under the hood' 对结果进行分页。