-->
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.  [ 5 posts ] 
Author Message
 Post subject: thow to execute select count(*) using SQL based query
PostPosted: Tue Jun 01, 2004 5:38 am 
Newbie

Joined: Thu Mar 04, 2004 3:24 am
Posts: 4
Hibernate 2.1.2 in Oracle10g app server.

code as following:
Query query = session.createSQLQuery("select count(*) cnt FROM PP_SCHOLARSHIP {ss} WHERE 1=1 and ss.COLLEGE_DISP like '%a%'",
"ss", com.onefbusa.cs.dataaccess.domaindata.college.Scholarship.class);
List lst = query.list();

exception throws:
net.sf.hibernate.JDBCException: SQLException occurred

can someone tell me thow to execute select count(*) using SQL Base Query.
thanks!

_________________
Bruce


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 7:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can't. use direct JDBC.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 7:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
btw, what you are doing there can be easily done with HQL.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 9:35 pm 
Newbie

Joined: Thu Mar 04, 2004 3:24 am
Posts: 4
michael wrote:
btw, what you are doing there can be easily done with HQL.


I am using Hibernate to implement pagination. For some functions, I can use HQL directly, however some functions contains specific oracle sql statement such as "contains" for text query and I think HQL can not support this function, so I want to use SQL Based Query API that Hibernate provides.

_________________
Bruce


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Using CONTAINS() in the where clause is no problem for HQL.
Have you tried it?


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

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.