Hibernate version: 3.0
Mapping documents: none for this case
Code between sessionFactory.openSession() and session.close():
Code:
SQLQueryImpl theQuery = (SQLQueryImpl)session.createSQLQuery(sqlString);
theQuery.addScalar("startdate", Hibernate.TIMESTAMP)
.addScalar("enddate", Hibernate.TIMESTAMP)
.addScalar("STANDARD", Hibernate.LONG)
.addScalar("pri", Hibernate.LONG)
.addScalar("building", Hibernate.STRING)
.addScalar("rcc", Hibernate.STRING)
.addScalar("stockno", Hibernate.STRING);
if (moreDetails != null)
{
theQuery.addScalar("manifest", Hibernate.STRING)
.addScalar("ccn", Hibernate.STRING)
.addScalar("docno", Hibernate.STRING)
.addScalar("pickdate", Hibernate.TIMESTAMP)
.addScalar("manifestdate", Hibernate.TIMESTAMP);
}
if (timeFrame == criticalTimeFrame)
{
theQuery.addScalar("palletid", Hibernate.LONG);
}
Iterator i = theQuery.list().iterator();
Object[] next = null;
while (i.hasNext())
{
next = (Object[])i.next();
.........//code ommitted for clarification
Name and version of the database you are using:Oracle 9i
Here's my question. This code works fine. It returns 43500 rows of data.
Creating these Object[] 's takes a considerably long time. So the query takes about a minute. The query itself when i run it from toad only takes about 4 seconds before it displays the results. I changed the code to scroll() instead of list(). It returned really quickly (about 5 seconds) but then it takes a really long time to scroll through the results and create the objects from the results.
I know it can be faster, because our current implementation using a ResultSet (non hibernate version) can complete everything consistently at around 15 seconds.
One other option I looked in to, but did not implement was the "select new" but I don't think it will work any faster, and I don't think it's possible with a createSQLQuery, and I don't want to convert the SQL query to HQL.
Does anyone have any suggestions as to how I might be able to speed up the returning of the results?
Thanks,
Nate[/code]