-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem using createSQLQuery with Oracle 10g query
PostPosted: Mon Dec 21, 2009 4:58 pm 
Newbie

Joined: Fri Dec 18, 2009 2:34 pm
Posts: 1
Hello:

I was hoping someone might point me in a direction. The following query in Oracle returns the 25th to 50th records:

select * from (select a.*, ROWNUM rnum from ( select * from program order by id) a where ROWNUM <= 50 ) where rnum >= 25;

I need to use createSQLQuery to run this query, so I tried the following code:

List<Program> retVal3 = getHibernateTemplate().getSessionFactory().getCurrentSession()
.createSQLQuery("select * from (select a.*, ROWNUM rnum from ( select * from rtipsuser.program order by id) a where ROWNUM <= 50 ) where rnum >= 25")
.addEntity(gov.nih.nci.rtips.dbi.domain.Program.class)
.list();

I turned the Hibernate show_sql on and got the following error:

Hibernate: select * from (select a.*, ROWNUM rnum from ( select * from rtipsuser
.program order by id) a where ROWNUM <= 50 ) where rnum >= 25
ERROR [JDBCExceptionReporter.java : 101] Invalid column name

When I run the same query in SQL, works fine, all columns are returned. Had this worked, I was then going to start adding addJoin() lines for each of the one-to-many tables linked by the program table, e.g.,

.addJoin("program.rtipsAppUsers");

We are using Hibernate 3.3.1, according to the Hibernate.jar manifest file.

thank you in advance for any advice.
--Harvey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.