Environment description:
NHibernate v1.0.2.0
ASP.Net 2.0 with C#
Oracle 10g database server
Code between sessionFactory.openSession() and session.close():
I tried different approaches:
Code:
IQuery q = session.CreateQuery(hql.Query());
q.SetProperties(criteriaDriver);
drivers = (ArrayList)q.List();
hql.Query() is just a simple class that builds a query like "From Driver dr where dr.FirstName = :FirstName".
The parameters are then bound to the corresponding properties criteriaDriver object.
The second try:
Code:
ICriteria crit = session.CreateCriteria();
crit.Add(Expression.Like("LastName", criteriaDriver.Name, MatchMode.Anywhere));
drivers = (ArrayList)crit.List();
Another try:
Code:
drivers = (ArrayList)session.Find(hql.Query(), hql.Params(), hql.Types());
... using the same hql class as in the first example, only this time the parameters are passed in with 2 arrays (Object[] for values and IType[] for types)
I also tried:
Code:
IEnumerable enum = session.Enumerable(hql.Query(), hql.Params(), hql.Types());
On to the problem:
I have a query that returns 5900 drivers, each has about 20 properties and an Iesi.Collections.ISet with distances. I (think I) use lazy loading correctly for this set. The first time I run this query, it returns in 1.5 seconds (which is acceptable), when I run the exact same query again, it takes 16 seconds to return!!! I timed the execution of the query's (so not including building up session and transaction) I would expect to see the execution time go down the second time!
Can anyone give me a clue to what I could be doing wrong?