OpenSession is not taking 2 seconds. 2 seconds is the time it is taking to get an object with certain
id using session.Get method. The 2 seconds is the time it is taking for second time. First call to session.Get takes 10 seconds. I am not able to find the reason why it is taking 10 seconds for the first time and just 2 seconds second time. session.Get is invoked on two different sessions. so no question of session using first level cache. I do not even enabled second level cache. Sravan On Thu, Sep 17, 2009 at 7:17 PM, Fabio Maulo <[email protected]> wrote: > An OpenSession 2 seconds is simply unacceptable. You are doing something > wrong somewhere. > > 2009/9/17 sravan <[email protected]> > > >> I have a Get Method that takes the ID of the entity and gives the >> object with that ID. >> >> In the Get Method I open a new session and calls Get on the session. >> >> the first call to get takes 10 sec, but subsequent calls to get takes >> just 2 seconds. >> >> I do not have second level caching enabled. >> >> I ran the sql server profiler and it is taking the same time to >> execute the query in both the cases. >> >> Not able to figure out why it is taking so long time for first call to >> get. >> >> Any help is Greatly appreciated. >> >> The second call is invoked on a different session. >> >> public virtual T Get( long ID ) >> { >> >> if ( null == Interceptor ) throw new TechnicalException >> ( "RepositoryBase::Get: ERROR: Interceptor must be set prior to use of >> this class." ); >> >> T entity = null; >> using ( ISession session = >> NHibernateSessionFactorySingleton.GetSession( Interceptor ) ) >> { >> using ( ITransaction transaction = >> session.BeginTransaction( ) ) >> { >> >> session.FlushMode = >> FlushMode.Never; >> >> T entity = session.Get<T>( ID ); >> >> transaction.Commit( ); >> } >> >> } >> >> >> return entity; >> } >> >> >> Sravan >> >> > > > -- > Fabio Maulo > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
