Hibernate 2.1.4
Sybase 12.5
When I run this select count(*) via hibernate it takes a long time. Over 2 minutes. When I run the EXACT same query that hibernate generates, just via JDBC it runs as expected, less than a second. (I ran this test in the same place I ran the hibernate query, even retrieved the Connection via the same Session.connection(), so the environment was exactly the same).
I was thinking it had something to do with the transaction isolation, but doing a select @@isolation returns 1, right before running the query.
I'm at a complete loss here. Is there anything I can look at or try to figure out why running the select count(*) in hibernate takes SUCH a long time? Could Hibernate or C3P0 be setting the isolation level before and right after the query is done?
Thanks!
Code:
Query query = session.getNamedQuery("selectCountSurveyBatchEmailsQueued");
query.setParameter("survey", surveyBatches[0].getSurvey());
query.setParameter("xsurvey", surveyBatches[0].getSurvey());
query.setParameterList("batchNos", batchNos);
query.setParameterList("xbatchNos", batchNos);
query.setParameterList("completionStatuses", completionStatuses);
query.setParameter("email", email);
List list = query.list();
count = (Integer) list.get(0);
<query name="selectCountSurveyBatchEmailsQueued">
<![CDATA[
SELECT count(*)
FROM PanelSurvey panelSurvey
WHERE panelSurvey.survey=:survey AND panelSurvey.batchNo IN (:batchNos)
AND panelSurvey.completionStatus IN (:completionStatuses)
AND panelSurvey.panel NOT IN (
SELECT panelSurveyEmailLog.panel
FROM PanelSurveyEmailLog panelSurveyEmailLog
WHERE panelSurveyEmailLog.email=:email AND panelSurveyEmailLog.survey=:xsurvey
AND panelSurveyEmailLog.batchNo IN (:xbatchNos))
]]>
</query>
[/code]