srilkrishna wrote:
Hi,
I have just started working on Hibernate.
I have a doubt about subqueries.
My query in Oracle is
select * from ( select * from tabelname where ID=12 order by dtCreation desc ) where rownum <= 4;
Please let me know how I can use the query in hibernate.
Thanks in advance.
Sri.
How about just keeping things simple...
In Hibernate you select from an Object not a table. instead of trying to do everything in one go, just break it up.
HQL1: "from tablename where bla bla bla" will give you your table name, you can then use a simple if statment to convert this to your fully qualified Object name which should be the same as MyObject.class.getName() for example.
Then you can do your 2nd peice of HQL.
HQL2: "from <Object name from if statment before> where bla bla"
There isn't any need to do everything in one statement as you did with SQL. Keep things simple with Hibernate and you'll get on with it much better.