Home:ALL Converter>Using of ORACLE rowId in Hibernate Criteria

Using of ORACLE rowId in Hibernate Criteria

Ask Time:2013-03-04T18:21:31         Author:pe4enko

Json Formatter

I have ORACLE DB and 2 tables. I need select rows from table1 inner join table2 and order by ORACLE RowID column. To select I use criteria query. To add order by statement I use

criteria.addOrder(Order.asc("this.rowId"));

In mapping RowId look like

<property name="rowId" column="ROWID" insert="false" update="false"/>

But hibernate generate wrong sql query like

select this_.docId as attr0_, this_.name as attr1_ from table1 this_ inner join table2 t2_ on this_.docId=t2_.docId order by ROWID asc

Hibernate drop alias "this" from query. Because all tables in ORACLE has ROWID column, we have oracle error ORA-00918

How i can write correct query by hibernate criteria to order by oracle RowId column?

Author:pe4enko,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/15199273/using-of-oracle-rowid-in-hibernate-criteria
yy